Sie sind auf Seite 1von 2

Class Test{

int max (int a, int b, int c, int d){


int f=a;
if(f<b)
f=b;
if(f<c)
f=c;
f(f<d)
f=d;
return f;
int min (int x, int y, int z, int w){
int g=x;
if(g>y)
g=y;
if(g>z)
g=z;
if(g>w)
g=w;
return g;
}*
}
2*
void diairesi (int w){
if(w%2==0||w%3==0||w%5==0)
System.out.println("diaireite");
else
System.out.println("den diaireite");
}

int Fib(int m){


int f0=0;
int f1=1;
int f2=f0+f1;
while (f2<m){
f0=f1;
f1=f2;
f2=f1+f2;
}
return f2;

int factorial (int n){


int f=1;
while (n>1);
f*=n--;
return f;

}
double pow(double x, int k){
if(k>0){

double y=1;
for (int i=1; i<=k; i++)
y=y*x;
if(y==Math pow(x,k))
return y;
else
System.out.println("wrong result");
return 0;
}
else{
System.out.println("wrong result");
return 0;
}
}
long p(int n, int k){
long p=1;
for (int i=0; i<k; i++)
p*=n--;
return p;
}
void sum(int n){
int i=1;
int sum=0;
do{
sum+=i++;
}while(i<n);
System.out.println("n= "+n);
System.out.println("sum= "+ sum)'
System.out.println("n*(n+1)/2= " +n*(n+1
)/2);
}
}//telos klasis Test
class ShowTest{
public static void main(string[] args){
Test a= new Test;
System.out.println("max= "+ a.max(5,6,7,8));
System.out.println("min= "+ a.min(5,6,7,8));
System.out.println("diairesei= "+ a.diairesi(8));
System.out.println("fib= "+a.fib(8));
System.out.println("factorial= "+ a.factorial(8));
System.out.println("dynami= "+ a.pow(2,3));
System.out.println("epanalipsis= "+a.p(8,6)+a.sum(16));
}//telos methodou main
}//tellos klasis Showtest
//den to katalava tipota

Das könnte Ihnen auch gefallen