-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathISE105.cpp
2828 lines (2091 loc) · 51.2 KB
/
ISE105.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <iomanip>
#include <math.h>
#include <locale.h>
#include <conio.h>
#include <windows.h>
#include <ctime>
#include <cmath>
#include <string>
#include <fstream>
#include <algorithm>
#include <cctype>
#include <cstring>
using namespace std;
/* // Hello World
//Nesne ya da fonksiyon arşivlerinin kullanımında, arşivlerdeki
//değişkenler ile kendi yazdığınız programınız içerisindeki
//değişkenlerin isimleri çakışabilir. Bu durumda derleme hatası ile
//karşılaşabilirsiniz. C++ bu problemi namespace ile çözmüştür
int main ()
{
cout<<"Hello World"<<endl;
system("pause");
return 0;
}
*/
/* // sayı sapma ve tahmini değer
int main() {
float sayi,sapma,tahmin;
cout <<"Sayiyi giriniz : ";
cin>>sayi;
cout<<"Sapma degerini giriniz : ";
cin>>sapma;
cout<<"Tahmin degerini giriniz : ";
cin>>tahmin;
while (abs(sayi - tahmin * tahmin) > sapma) {
tahmin = (tahmin + sayi / tahmin) / 2;
}
cout<<tahmin;
system("pause");
return 0;
}
*/
/* // fahrenheit derece dönüşümü
int main()
{
char ch, secenek;
float fSicaklik, cSicaklik, sicaklik;
do
{
cout << "Fahrenheit'dan Celsius'a cevirmek icin : f" << endl;
cout << "Celsius'dan Fahrenheit'e cevirmek icin : c" << endl;
cout << "seciminiz : ";
cin >> secenek;
if (secenek == 'f')
{
cout << "F sicaklik degerini giriniz : " << endl;
cin >> sicaklik;
cSicaklik = (sicaklik - 32) * 5 / 9;
cout << "Celsius olarak : " << cSicaklik << "\370" << 'C' << endl;
}
else if (secenek == 'c')
{
cout << "C sicaklik degerini giriniz : " << endl;
cin >> sicaklik;
fSicaklik = (sicaklik * 9/5) + 32;
cout << "Fahrenheit olarak : " << fSicaklik << "\370" << 'F' << endl;
}
else
{
cout << "Lutfen Yukarida Verilen Karakterlerden Birini Giriniz!" << endl;
}
do
{
cout << "\nbaska islem (e/h) : " << endl;
cin >> ch;
}while (!(ch == 'e' || ch == 'h'));
} while (ch != 'h');
system("pause");
return 0;
}
*/
/* // dairenin yarıcapını hesaplama
int main()
{
float yaricap;
const float PI = 3.14F; //const pi, e gibi özel ifadeler için
float alan;
cout << "Dairenin yari capi";
cin >> yaricap;
alan = PI * yaricap * yaricap;
//float alan = PI * yaricap * yaricap
cout << "Alan degeri: " << alan << endl;
system("pause");
return 0;
}
*/
/* // numaralandıma(enum)
enum haftanin_gunleri { Pzt=20, Sa, Car=30, Pers, Cu, Cts, Pz };
int main()
{
haftanin_gunleri gun1, gun2;
gun1 = Pzt;
gun2 = Car;
int fark = gun2 - gun1;
cout << "Gunler arasindaki fark =" << fark << endl;
system("pause");
return 0;
}
*/
/* // setfill kullanımı
int main ()
{
long A = 1234567, B = 123, C = 2345;
cout << setfill('-') << setw(10) << 11 << endl;
cout << setfill('-') << setw(10) << 2222 << endl;
cout << setfill('-') << setw(10) << 33333 << endl;
cout << setfill('-') << setw(10) << 4 << endl;
system("pause");
return 0;
}
*/
/* // isim bölüm ve numara yazdırma
int main()
{
setlocale(LC_ALL, "Turkish");
cout << "Yusuf Gulmez" <<endl;
cout << "Bilisim Muhendisligi" <<endl;
cout << "B20*******" <<endl;
system("PAUSE");
return 0;
}
*/
/* // ++sayi, sayi++, gibi ifadelerle (k,l,m,..) bilinmeyenleri bulma
int main ()
{
int sayi;
sayi = 10;
int k = ++sayi;
int l = sayi++;
int m = l--;
cout << "k = " << k << endl << "l = " << l << endl << "m = " << m << endl << "sayi = " << sayi << endl;
system("pause");
return 0;
}
*/
/* // karakter yazdırma
int main()
{
char ch1 = 'Y';
char ch2 = 'G';
char ch3 = '\t';
cout << ch1 << ch3 << ch2 << endl;
system("pause");
return 0;
}
*/
/* // tablo oluşturma (sola ve sağa yatık yazma) (<< left <<)
int main ()
{
long A = 1234567, B = 123, C = 2345, D = 47821, E = 9350, F = 349;
// cout << setw(4) << "A" << setw(14) << A << endl; x+4=14 2. Çözüm
// cout << setw(4) << "B" << setw(10) << B << endl; x=10
// cout << setw(4) << "C" << setw(11) << C << endl; x+1=11
cout << setw(10) << "E" << setw(20) << E << endl;
cout << setw(10) << "D" << setw(20) << D << endl; // 1. çözüm
cout << setw(10) << "F" << setw(20) << F << endl;
system("pause");
return 0;
}
*/
/* // iki sayıyı çarpma (int*float)
int main()
{
int tamsayi = 7;
float kayannokta = 155.5F;
double sonuc = tamsayi * kayannokta;
cout << "SONUC....:" << sonuc << endl;
system("pause");
return 0;
}
*/
/* // ASCI karşılığı bulma
int main()
{
char ch1 = _getch();
cout << ch1 << " karakterin ASCI karsiligi : " << static_cast<int>(ch1) << endl;
system("pause");
return 0;
}
*/
/* // Karekök Hesaplama
int main()
{
setlocale(LC_ALL, "Turkish");
double sayi, sonuc;
cout << "bir sayi giriniz:" ;
cin >> sayi;
sonuc = sqrt(sayi); //sqrt() fonk double veri tipi alır
cout << sayi << "sayının karekoku:" << sonuc << endl;
system("pause");
return 0;
}
*/
/* // girilen sayının, tahmini karekökünü ve hata değerini girip karekökünü hesaplama
int main ()
{
float a, x, e, b, y;
cout << "karekökü bulunacacak olan sayı : ";
cin >> a;
cout << "tahmini karekök değerini giriniz : ";
cin >> x;
cout << "kabul edilebilir hata değerini giriniz : ";
cin >> e;
do
{
b = (a - x * x) / (2 * x);
y = x + b; //yeni karekök değeri
cout << x << endl;
x = y;
}while (fabs(b) > e);
cout << "karekök : " << y << endl;
system("PAUSE");
return 0;
}
*/
/* // Hesap Makinesi (if-else if- else)
int main() {
int a,b;
string islem;
cout << "hesap makinesine hos geldiniz.." << endl;
cout << "+" << endl;
cout << "-" << endl;
cout << "*" << endl;
cout << "/" << endl;
cout << "islem giriniz" << endl;
cin >> islem;
if (islem == "+") {
cout << "a:";
cin >> a;
cout << "b:";
cin >> b;
cout << "toplam : " << a + b << endl;
}
else if (islem == "-") {
cout << "a:";
cin >> a;
cout << "b:";
cin >> b;
cout << "fark : " << a - b << endl;
}
else if (islem == "*") {
cout << "a:";
cin >> a;
cout << "b:";
cin >> b;
cout << "çarpım : " << a * b << endl;
}
else if (islem == "/") {
cout << "a:";
cin >> a;
cout << "b:";
cin >> b;
cout << "bölüm : " << a / b << endl;
}
else {
cout << "error" << endl;
}
system("pause");
return 0;
}
*/
/* // iki sayının ortalamsını hesaplama
int main () {
float x, y;
cout << "iki sayı giriniz" << endl;
cin >> x >> y;
cout << "" << endl;
cout << "ortalama : " << (x + y)/2 << endl;
system ("pause");
return 0;
}
*/
/* // iki sayıyı karşılaştırma
int main () {
int sayi1, sayi2;
cout << "iki sayi giriniz : \n" ;
cin >> sayi1 >> sayi2;
if ( sayi1 < sayi2 ) {
cout << sayi1 << " " << sayi2 << "'den kucuk...\n";
}
else if ( sayi1 > sayi2) {
cout << sayi2 << " " << sayi1 << "'den kucuk...\n";
}
else if (sayi1 == sayi2) {
cout << "sayi1 = sayi2 \n" ;
}
else
cout << "yanlis girdiniz" << endl;
system ("pause");
return 0;
}
*/
/* // Girilen Vize ve Final Notlarından Ortalama Hesaplama ve Geçip-Kalma
int main () {
setlocale(LC_ALL, "Turkish");
int vize, final;
cout << "vize ve final notunu girin : \n";
cin >> vize >> final ;
float ort = (vize*0.4 + final*0.6);
cout << "ortalamaniz : " << ort << endl;
if (ort < 50 || final < 50) {
// if(final < 50)
cout << "kaldiniz" << endl;
}
else {
cout << "gectiniz" << endl;
}
system("pause");
return 0;
}
*/
/* // Girilen Ortalamanın Harf Karşılığı
int main () {
int ort;
cout << "ortalama giriniz : " << endl;
cin >> ort;
if ( ort >= 90) {
cout << "AA\n";
}
else if ( ort >= 80) {
cout << "BB\n";
}
else if ( ort >= 70) {
cout << "CC\n";
}
else if ( ort >= 50) {
cout << "DD\n";
}
else
cout << "FF\n";
system("pause");
return 0;
}
*/
/* // Üç Basamaklı Rakamları Birbirinden Farklı Kaç Sayı Var
int main()
{
int sayac = 0;
int i;
int a,b,c;
for ( i = 100; i <= 999; i++)
{
a = i/100;
b = (i/10)%10;
c = i%10;
if (a!=b && a!=c && b!=c)
{
sayac++;
}
}
cout << sayac << endl;
system("pause");
return 0;
}
*/
/* // Hesap Makinesi (switch-case-break)
int main() {
char islem;
int sayi1, sayi2;
cout << "2 sayi girin" << endl;
cin >> sayi1 >> sayi2;
cout << "yapmak istediginiz islemi seciniz. ( + , - , * , / ): " << endl;
cin >> islem;
switch(islem)
{
case '+':
cout << sayi1 + sayi2 ;
break;
case '-':
cout << sayi1 - sayi2 ;
break;
case '*':
cout << sayi1 * sayi2 ;
break;
case '/':
cout << sayi1 / sayi2 ;
break;
default:
cout << "yanlis islem girdiniz" << endl;
}
system("pause") ;
return 0;
}
*/
/* // 1'den 100'e kadar olan sayıların küpleri
int main() {
for (int i =1; i <= 100; i++)
{
cout << setw(10) << left << i << setw(15) << pow(i,3) << endl;
}
system("pause");
return 0;
}
*/
/* // 0-1000 arasındaki tek ve çiftlerin sayısı, toplamı ve ortalması
int main () {
int teksayac=0, tektoplam=0, tekort=0, ciftsayac=0, cifttoplam=0, ciftort=0;
for ( int i = 1; i <= 1000 ; i++)
{
if(i % 2 == 0)
{
ciftsayac++;
cifttoplam +=i;
}
else
{
teksayac++;
tektoplam +=i;
}
}
ciftort = cifttoplam / ciftsayac;
tekort = tektoplam / teksayac;
cout << "Tek Sayıların Sayısı : " << teksayac << endl;
cout << "Tek Sayıların Toplamı : " << tektoplam << endl;
cout << "Tek Sayıların Ortalaması : " << tekort << endl;
cout << "-------------------------------------------"<<endl;
cout << "Çift Sayıların Sayısı : " << ciftsayac << endl;
cout << "Çift Sayıların Toplamı : " << cifttoplam << endl;
cout << "Çift Sayıların Ortalaması : " << ciftort << endl;
system("pause");
return 0;
}
*/
/* // 1' den 10'a kadar olan sayıları topla
int main () {
int toplam = 0;
for (int sayac = 1; sayac <= 10; sayac++)
{
toplam += sayac;
cout << "Toplam = " << toplam << endl;
}
system("pause") ;
return 0;
}
*/
/* // mükemmel sayisi (Vize Sourusu)
int main() {
int sayi;
int toplam = 0;
cout << "Sayi giriniz:";
cin >> sayi;
for (int i = 1 ; i < sayi ; i++)
{
if (sayi % i == 0) {
toplam = toplam + i;
}
}
if (toplam == sayi)
cout << "Sayiniz mukemmel sayisidir." << endl;
else cout << "Sayiniz mukemmel sayisi degildir." << endl;
system("PAUSE");
return 0;
}
*/
/* // Faktöriyel hesaplayan program
int main() {
unsigned int sayi; //unsigned işaretsiz demek negatif sayıları da alması için kullan
unsigned long fakt = 1;
cout << "Bir sayı girin : ";
cin >> sayi;
for (int i = sayi; i > 0; i--)
{
fakt *= i; //sayi, sayi-1, ..., 2, 1
}
cout << sayi << "! = " << fakt << endl;
system("pause");
return 0;
}
*/
/* // fibonacci serisi (if - else if - else - for)
int main()
{
int n;
cout << "bir sayi giriniz : ";
cin >> n;
int a = 1;
int b = 1;
if (n==1)
{
cout << 1 << endl;
}
else if (n<=0);
else
{
cout << a << endl << b << endl;
for (int i = 0; i < n; i++)
{
int c = a + b;
a = b;
b = c;
cout << c << endl;
}
}
system("pause");
return 0;
}
*/
/* // While döngüsü ile 1'den 100'e kadar olan sayıların küplerini ekrana yazdırma
int main() {
int i = 1;
while (i <= 100)
{
cout << setw(10) << left << i << setw(15) << pow(i,3) << endl;
i++;
}
system("pause");
return 0;
}
*/
/* // while döngüsü tek ve çiftlerin sayısı-toplamı
int main()
{
int teksayac = 0, tektoplam = 0, ciftsayac = 0, cifttoplam = 0 ;
int sayi;
cout << "sayı giriniz : " ;
cin >> sayi;
while (sayi != 0)
{
if (sayi % 2 == 0)
{
ciftsayac++;
cifttoplam += sayi;
}
else
{
teksayac++;
tektoplam += sayi;
}
cout << "tek adedi : " << teksayac << endl;
cout << "tek toplam : " << tektoplam << endl;
cout << "cift adedi : " << ciftsayac << endl;
cout << "cift toplam : " << cifttoplam << endl;
cout << "sayı giriniz : ";
cin >> sayi;
}
system("pause");
return 0;
}
*/
/* // Dördüncü kuvvet değeri 10000'den küçük olan sayıları ve kuvvet
değerlerini ekrana yazdıran program
using namespace std;
int main ()
{
int sayi=0;
int kuvvet=0;
while(kuvvet <= 10000)
{
cout << left << setw(5) << kuvvet << endl;
cout << left << setw(2) << sayi;
++sayi;
kuvvet = sayi*sayi*sayi*sayi;
}
system("pause");
return 0;
}
*/
/* // do-while ile 1' den 100' e kadar olan sayıların küplerini ekrana yazdıaran program
int main()
{
int i=1;
do
{
cout << setw(10) << left << i << setw(15) << pow(i,3) << endl;
i++;
} while (i <= 100);
system("pause");
return 0;
}
*/
/* // do-while ile 1' den n'e kadar olan sayıların toplamı
int main ()
{
int sayac = 0, toplam = 0;
int n;
cout << "n'e bir değer veriniz : ";
cin >> n;
do
{
toplam += sayac;
sayac++;
} while (sayac <= n);
cout << "toplam = " << toplam << endl;
system("pause");
return 0;
}
*/
/* // do while ile tek ve ciftlerin sayısını bulma
int main ()
{
int tektoplam = 0, teksayac = 0, ciftoplam = 0, ciftsayac = 0;
int sayi;
do
{
cout << "bir sayı girin : ";
cin >> sayi;
if (sayi > 0)
{
if (sayi % 2 == 0)
{
ciftsayac++;
ciftoplam += sayi;
}
else
{
teksayac++;
tektoplam += sayi;
}
}
}while(sayi > 0);
cout << "teklerin sayısı : " << teksayac << endl;
cout << "teklerin toplamı : " << tektoplam << endl;
cout << "çiftlerin sayısı : " << ciftsayac << endl;
cout << "çiftlerin toplamı : " << ciftoplam << endl;
system("pause;");
return 0;
}
*/
/* // Continue = 1'den 10'a kadar olan sayıların küpü ama continue ile bir sayıyı atlama
int i = 0;
int main ()
{
for ( i = 1; i <= 10; i++)
{
if (i == 5)
continue;
cout << setw(10) << left << i << setw(15) << pow(i,3) << endl;
}
cout << "i = " << i << endl;
system("pause");
return 0;
}
*/
/* // do while ile hesap makinesi yapma
int main ()
{
char islem, ch;
int sayi1, sayi2;
do
{
cout << "işlem türü seç : (+,-,*,/)" << endl;
cin >> islem;
cout << "sayı 1 : ";
cin >> sayi1;
cout << "sayı 2 : ";
cin >> sayi2;
switch (islem)
{
case '+':
cout << sayi1 << "+" << sayi2 << "=" << sayi1 + sayi2;
break;
case '-':
cout << sayi1 << "-" << sayi2 << "=" << sayi1 - sayi2;
break;
case '*':
cout << sayi1 << "*" << sayi2 << "=" << sayi1 * sayi2;
break;
case '/':
cout << sayi1 << "/" << sayi2 << "=" << sayi1 / sayi2;
break;
default:
cout << "hata..!";
break;
}
do
{
cout << "\nbaska islem (e/h) : ";
cin >> ch;
} while (!(ch == 'e' || ch == 'h'));
} while (ch != 'h');
system("pause");
return 0;
}
*/
/* // girilen kelimenin kaç harften oluştuğunu bulan program
int main()
{
int harfsayac=0;
int kelimesayac=1;
char ch = 'a';
cout << "bir cumle giriniz .: ";
while( ch != '\r' )