get rid of cmake, simplfy directory structure
This commit is contained in:
96
YZM502/vize.c
Normal file
96
YZM502/vize.c
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "stdio.h"
|
||||
|
||||
void tekCift() {
|
||||
int sayi;
|
||||
printf("Bir sayi giriniz: ");
|
||||
scanf("%d", &sayi);
|
||||
|
||||
if (sayi % 2 == 0) {
|
||||
printf("%d ÇİFTTİR!", sayi);
|
||||
} else {
|
||||
printf("%d TEKDİR!", sayi);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void sirala() {
|
||||
int sayi[3];
|
||||
int i,j,tmp;
|
||||
for (i =0; i < 3; i++) {
|
||||
printf("%d. Sayı: ", i+1);
|
||||
scanf("%d", &sayi[i]);
|
||||
}
|
||||
|
||||
for (i=0; i<3; i++) {
|
||||
for (j=0; j<3-i-1; j++) {
|
||||
if (sayi[j]>sayi[j+1]) {
|
||||
tmp = sayi[j];
|
||||
sayi[j] = sayi[j+1];
|
||||
sayi[j+1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n------------------------------\n");
|
||||
|
||||
for (i =0; i < 3; i++) {
|
||||
printf("%d\t", sayi[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void asal() {
|
||||
int sayi, i;
|
||||
printf("Bir sayi giriniz: ");
|
||||
scanf("%d", &sayi);
|
||||
|
||||
for (i=2; i<sayi; i++) {
|
||||
if (sayi % i == 0) {
|
||||
printf("%d asal DEĞİLDİR!", sayi);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d ASALDIR!", sayi);
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int secim = 0;
|
||||
|
||||
printf("\n\n-------------------------------------------------\n");
|
||||
printf("(1) Girilen sayının Tek Yada Çift Olduğunu Bulma \n");
|
||||
printf("(2) Girilen 3 sayıyı büyükten küçüğe sıralama \n");
|
||||
printf("(3) Girilen Sayının Asal sayı olup olmadığını bulma \n");
|
||||
printf("ÇIKIŞ İÇİN : -1 \n");
|
||||
printf("-------------------------------------------------\n\n");
|
||||
|
||||
printf("Seçiminizi Giriniz: ");
|
||||
|
||||
do {
|
||||
scanf("%d", &secim);
|
||||
if ((secim < 1 || secim > 3) && (secim != -1)) {
|
||||
printf("\nYanlış değer girdiniz tekrar giriş yapınız: ");
|
||||
}
|
||||
|
||||
} while ((secim < 1 || secim > 3) && (secim != -1));
|
||||
return secim;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int secim = 0;
|
||||
|
||||
do {
|
||||
secim = menu();
|
||||
switch (secim) {
|
||||
case 1:
|
||||
tekCift();
|
||||
break;
|
||||
case 2:
|
||||
sirala();
|
||||
break;
|
||||
case 3:
|
||||
asal();
|
||||
break;
|
||||
}
|
||||
} while (secim != -1);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user