#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define UZUNLUK 10
int main()
{
int x[10]={0},i,a;
printf("10 farkli sayi giriniz:");
for (i=0;i<10;i++){
printf("\n%d. sayi:",i+1);
scanf("%d",&x[i]);
for(a=i-1;a>=0;a--){
if(x[i]==x[a]){
printf("\nlütfen baska sayi giriniz:");
scanf("%d",&x[i]);
}
}
}
return 0;
system ("pause");
}
--------------------------------------
#include <stdio.h>
#include <conio.h>
int main(){
int x[10],i,a,b;
double sum=0,ort;
for(i=0;i<10;i++){
printf ("%d.sayiyi giriniz:",i+1);
scanf("%d",&x[i]);
sum=sum+x[i];
ort=sum/(i+1);
printf("%lf\n",ort);
}
for(i=0;i<10;i++){
printf("%d\n",x[i]);
}
}
--------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define UZUNLUK 10
int main(){
int y[20],n;
srand(time(NULL));
y[0]=5;
y[1]=3;
for(n=2;n<20;n++){
y[n]=(3*y[n-2])-y[n-1];
}
printf("lutfen n degeri giriniz:");
scanf("%d",&n);
for(;n>20;)
if(n>20){
printf("lutfen baska bir n sayisi giriniz");
scanf("%d",&n);
}
printf("%d\n",y[n]);
}
--------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define UZUNLUK 10
int foo(int dz[],int *x,int *y){
int max=0,min=101,max2=0,min2=101;
int i,e,r,a=0,b=0;
for(i=0;i<10;i++){
if(dz[i]>max){
max=dz[i];
e=i;
}
}
a=dz[e];
dz[e]=0;
for(i=0;i<10;i++){
if(dz[i]>max2)
max2=dz[i];
}
dz[e]=a;
*x=max2;
for(i=0;i<10;i++){
if(dz[i]<min){
min=dz[i];
r=i;
}
}
b=dz[r];
dz[r]=101;
for(i=0;i<10;i++){
if(dz[i]<min2)
min2=dz[i];
}
dz[r]=b;
*y=min2;
}
void main(){
int i,sayilar[UZUNLUK],max2,min2;
srand(time(NULL));
for(i=0;i<UZUNLUK;i++){
sayilar[i]=rand() %100;
printf("sayi[%d]=%d\n",i,sayilar[i]);
}
foo(sayilar,&max2,&min2);
printf("en buyuk 2. sayi : %d\nen kucuk 2. sayi: %d\n",max2,min2);
}
Hiç yorum yok:
Yorum Gönder