ipt final-1
This commit is contained in:
69
YZM502/final/soru1/.gitignore
vendored
Normal file
69
YZM502/final/soru1/.gitignore
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
### C template
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
### CMake template
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
|
||||
/cmake-build-debug/
|
||||
/.idea/
|
||||
7
YZM502/final/soru1/CMakeLists.txt
Normal file
7
YZM502/final/soru1/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(soru1 C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
add_executable(soru1 main.c)
|
||||
target_link_libraries(soru1 PRIVATE m)
|
||||
123
YZM502/final/soru1/main.c
Normal file
123
YZM502/final/soru1/main.c
Normal file
@@ -0,0 +1,123 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int fibbonacci(int n) {
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
} else if (n == 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return (fibbonacci(n - 1) + fibbonacci(n - 2));
|
||||
}
|
||||
}
|
||||
|
||||
void fibbonacciYaz() {
|
||||
int n, i;
|
||||
printf("Bir sayi giriniz: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
for (i = 0; i <= n; i++) {
|
||||
printf("\nIndex: %d | Fibbonacci: %d", i, fibbonacci(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int faktoryel(long sayi) {
|
||||
if (sayi <= 1) {
|
||||
return sayi;
|
||||
} else {
|
||||
return (sayi * faktoryel(sayi - 1));
|
||||
}
|
||||
}
|
||||
|
||||
void faktoryelFormul() {
|
||||
int n;
|
||||
printf("Bir sayi giriniz: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
long nFak;
|
||||
long nEksiBirFak;
|
||||
long nArtiBirFak;
|
||||
double sonuc;
|
||||
|
||||
nFak = faktoryel(n);
|
||||
nEksiBirFak = faktoryel(n - 1);
|
||||
nArtiBirFak = faktoryel(n + 1);
|
||||
|
||||
sonuc = ((nFak * nEksiBirFak) * 1.0) / nArtiBirFak;
|
||||
|
||||
printf("\n*******************************");
|
||||
printf("\n Formül Soucu : %.6f", sonuc);
|
||||
printf("\n n: %d | n+1: %d | n-1: %d", nFak, nArtiBirFak, nEksiBirFak);
|
||||
printf("\n*******************************");
|
||||
}
|
||||
|
||||
void kokluFormul() {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
double sonuc;
|
||||
|
||||
printf("a: ");
|
||||
scanf("%d", &a);
|
||||
|
||||
printf("b: ");
|
||||
scanf("%d", &b);
|
||||
|
||||
printf("c: ");
|
||||
scanf("%d", &c);
|
||||
|
||||
double p1, p2, p3;
|
||||
|
||||
p1 = (-1 * b);
|
||||
p2 = sqrt((b * b) - (4 * a * c));
|
||||
p3 = (2 * a);
|
||||
|
||||
sonuc = (p1 + p2) / p3;
|
||||
|
||||
printf("\n*******************************");
|
||||
printf("\n Formül Soucu : %.10f", sonuc);
|
||||
printf("\n*******************************");
|
||||
}
|
||||
|
||||
int menu() {
|
||||
int secim = 0;
|
||||
|
||||
printf("\n\n-------------------------------------------------\n");
|
||||
printf("(1) Fibonacci dizimi hesaplama \n");
|
||||
printf("(2) n!(n-1)!/(n+1)! hesaplama \n");
|
||||
printf("(3) Formül hesaplama \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:
|
||||
fibbonacciYaz();
|
||||
break;
|
||||
case 2:
|
||||
faktoryelFormul();
|
||||
break;
|
||||
case 3:
|
||||
kokluFormul();
|
||||
break;
|
||||
}
|
||||
} while (secim != -1);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user