Συντονιστής: the_eye
lostinmyworld έγραψε:Αυτόν τον τύπο εννοείς;
http://el.wikipedia.org/wiki/%CE%A4%CF%8D%CF%80%CE%BF%CF%82_Stirling
Ναι, αλλά πώς υλοποιείται αυτός σε Java;;
import math
def StirlingFactorial(n):
return math.sqrt(2 * math.pi * n)*(n/math.e)**n
public class Stirling {
public static double Factorial (int n) {
return Math.sqrt(2 * Math.pi * n) * Math.pow( (n/Math.e),n)
}
}
idomeneas έγραψε:Από όσο θυμάμαι εγώ είχα αντιμετωπίσει ένα πρόβλημα με ένα πρόγραμμα CAD, σε Fortran, που έπρεπε να υπολογιστούν πολυώνυμα Bernstein για τις καμπύλες Bezier μέσω knot points. Αν έβαζες πάνω από κάποια σημεία για να ορίσεις την καμπύλη, τότε με integer δεν μπορούσες να βάλεις πάνω από 13 σημεία γιατί υπολόγιζες το 13 ! και γινόταν ανακύκλωση. Την έκανα real(8) για να αυξήσω κάπως το μέγεθος αλλά ως γνωστόν πάλι θα έβγαιναν "παππάδες" μετά από ένα όριο.
M.Jackson έγραψε:κάποιο δωρεάν βιβλίο (pdf) για δημιουργία γραφικού περιβάλλοντος αλλά με κώδικά όχι με κάποιο πρόγραμμα. παίζει τίποτα;
import javax.swing.JOptionPane;
import java.util.Random;
public class pro{
public static void main (String args []) throws Exception{
Random rnd = new Random();
int x=0;
String get;
int geted;
do{
for(int i=1; i<=10; i++){
x=rnd.nextInt(10);}
get = JOptionPane.showInputDialog("Dose ton arithmo sou");
geted = Integer.parseInt(get);
if(geted == x){
JOptionPane.showMessageDialog(null,"Well Done!");
}else{
JOptionPane.showMessageDialog(null,"Game Over! o arithmos sou ine: " + geted + " kai o randomize arithmos ine: " + x);}
}while(geted!=x);
}}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class pro extends JFrame implements ActionListener {
JButton b;
String in1;
String in2;
int pr,gr,d;
int max=-999;
int min=999;
double mo;
public pro(){
this.setSize(150,80);
this.setTitle("A Java Program");
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setLayout(new FlowLayout());
Container content = getContentPane();
b = new JButton("Start");
b.setActionCommand("Start");
b.addActionListener(this);
content.add(b, BorderLayout.NORTH);
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("Start")){
in1 = JOptionPane.showInputDialog("Dose proforiko vathmo");
in2 = JOptionPane.showInputDialog("Dose grapto vathmo");
pr = Integer.parseInt(in1);
gr = Integer.parseInt(in2);
if(pr>max){
max=pr;
min=gr;
}else{
min=pr;
max=gr;}
d=max-min;
if(d>3){
if(max==pr){
pr=pr-(d--);
}else{
if(min==pr){
pr=pr-(d++);}
}
}
mo = (pr+gr)/2;
JOptionPane.showMessageDialog(null, "Result: " + mo);
if(mo>=10){
JOptionPane.showMessageDialog(null, "PROAGETE");
}else{
JOptionPane.showMessageDialog(null, "STASIMOS");}
}
}
public static void main(String[] args) {
new pro();
}
}