Bunun Burada Ne İşi Var?
Dün şehre inmek için Sayın Menderes Türel’in zamanında Hafif Metro ...
Bu sene Algoritma ve Programlama dersi almamama rağmen hem birinci sınıflara yardımcı olsun, hem sitemin trafiği artsın
, hem de internetteki C kaynak kodu örnekleri artsın diye ödev çözümlerini sağdan soldan toplayıp paylaşıyorum.
Şaka bir yana, kodunu paylaştığı için Özlem’e çok teşekkür ediyorum. Umuyorum burada paylaşılanlar birinin işine yarar…
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 | #include <stdio.h> #include <stdlib.h> struct ogrenci { int ogr_no; char ad_soyad[25]; char sinif[3]; int basarili_ders_say; float not_ort; }; int menu() { int secim; printf("\n\n\n"); printf("************************************MENU************************************\n\n"); printf(" 1.Ogrencilerin basarili olduklari derslerin eklenmesi.\n"); printf(" 2.Bir ogrencinin kaydinin silinmesi.\n"); printf(" 3.Bir ogrencinin bilgilerinin listelenmesi.\n"); printf(" 4.Bir ogrencinin bilgilerinin ve basarili olduklari derslerin listelenmesi.\n"); printf(" 5.Belirli bir not ortalamasi uzerindeki ogrencilerin listelenmesi.\n"); printf(" 6.Bir sinifta okuyan ogrencilerin listelenmesi.\n"); printf(" 7.Okulun basari istatistiklerinin listelenmesi.\n"); printf(" 8.Bir dersten basarili olan ogrencilerin listelenmesi.\n"); printf(" 9.Cikis.\n\n"); printf("Seciminizi giriniz.\n\n"); scanf("%d",&secim); return secim; } void ders_ekle() { FILE *dosya; FILE *dosya2; char devam='E'; int ek_no,ek_kod,ek_not; float yeni_not_ort; struct ogrenci bir_ogr= { 0,"","",0,0.0 }; if((dosya=fopen("notlar.dat","a+"))== NULL) { printf("Notlar dosyasi acilamadi..\n\n"); } else { if((dosya2=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { while(devam=='E') { do { printf("Ogrencinin numarasini giriniz.\n"); scanf("%d",&ek_no); } while(ek_no>500 || ek_no<1); printf("Ders kodu ve ogrencinin gecme notunu aralarinda birer bosluk birakarak giriniz.\n\n"); fscanf(stdin,"%d%d",&ek_kod,&ek_not); fseek(dosya2,(ek_no-1)*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya2); yeni_not_ort=(bir_ogr.not_ort*bir_ogr.basarili_ders_say+ek_not)/(++bir_ogr.basarili_ders_say); fprintf(dosya,"%d %d %d\n",ek_no,ek_kod,ek_not); bir_ogr.not_ort=yeni_not_ort; fseek(dosya2,(ek_no-1)*sizeof(struct ogrenci),SEEK_SET); fwrite(&bir_ogr,sizeof(struct ogrenci),1,dosya2); printf("Kayit eklenmistir.\nYeni bir ekleme yapmak istiyor musunuz?-E ya da H giriniz-\n"); scanf("%s",&devam); } fclose(dosya2); } fclose(dosya); } return; } void kayit_sil() { FILE *dosya; FILE *dosya2; FILE *dosya3; int silinecek_no; int no,kod,not; struct ogrenci bir_ogr,bos_ogr= { 0,"","",0,0.0 }; if((dosya=fopen("notlar.dat","r"))== NULL) { printf("Notlar dosyasi acilamadi..\n\n"); } else { if((dosya2=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { dosya3=fopen("gecici.dat","a"); do { printf("Silinecek ogrencinin numarasini giriniz.\n"); scanf("%d",&silinecek_no); } while(silinecek_no>500 || silinecek_no<1); fseek(dosya2,(silinecek_no-1)*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya2); if(bir_ogr.ogr_no==0) { printf("Uzgunuz boyle bir ogrenci yoktur.\n"); } else { fseek(dosya2,(silinecek_no-1)*sizeof(struct ogrenci),SEEK_SET); fwrite(&bos_ogr,sizeof(struct ogrenci),1,dosya2); fscanf(dosya,"%d %d %d",&no,&kod,¬); while(!feof(dosya)) { if(silinecek_no!=no) { fprintf(dosya3,"%d %d %d\n",no,kod,not); } fscanf(dosya,"%d %d %d",&no,&kod,¬); } } fclose(dosya2); } fclose(dosya); fclose(dosya3); remove("notlar.dat") ; rename("gecici.dat","notlar.dat"); printf("Kayit silinmistir.\n"); } return; } void ogr_listele(int kontrol) { FILE *dosya; FILE *dosya2; int listelenecek_no; int no,kod,not; int bulundu=0; struct ogrenci bir_ogr; if((dosya=fopen("notlar.dat","a+"))== NULL) { printf("Notlar dosyasi acilamadi..\n\n"); } else { if((dosya2=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { do { printf("Listelenecek ogrencinin numarasini giriniz.\n"); scanf("%d",&listelenecek_no); } while(listelenecek_no>500 || listelenecek_no<1); fseek(dosya2,(listelenecek_no-1)*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya2); printf("Ogr no\tAd Soyad\tSinif\tBasarili Ders Say\tNot Ort\n"); printf("------\t--------\t-----\t-----------------\t-------\n"); printf("%d\t%s\t%s\t%d\t\t\t%.2f\n\n",bir_ogr.ogr_no,bir_ogr.ad_soyad,bir_ogr.sinif,bir_ogr.basarili_ders_say,bir_ogr.not_ort); if(kontrol==1) { printf("Basarili oldugu dersler:\n"); printf("Basarili ders kodu\tGecme Notu\n"); printf("------------------\t----------\n"); fscanf(dosya,"%d %d %d",&no,&kod,¬); while(!feof(dosya)) { if(no==bir_ogr.ogr_no) { printf("%d\t\t\t%d\n",kod,not); bulundu=1; } fscanf(dosya,"%d %d %d",&no,&kod,¬); } if(bulundu==0) { printf("Bu ogrenci tembel.\n\n"); } } fclose(dosya2); } fclose(dosya); } return; } void ortalamaya_gore_listele() { FILE *dosya; FILE *dosya2; float sinir; int i=0; long yer; struct ogrenci bir_ogr= { 0,"","",0,0.0 }; if((dosya=fopen("notlar.dat","a+"))== NULL) { printf("Notlar dosyasi acilamadi..\n\n"); } else { if((dosya2=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { printf("Ortalamayi giriniz.\n"); scanf("%f",&sinir); printf("Ogr No\tAd Soyad\tSinif\tBasarili Ders Say\tNot Ort\n"); printf("------\t--------\t-----\t-----------------\t-------\n"); fseek(dosya2,0,SEEK_END); yer=ftell(dosya2); yer/=sizeof(struct ogrenci); while(i<yer) { fseek(dosya2,i*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya2); if(bir_ogr.not_ort>sinir) { printf("%d\t%s\t%s\t%d\t\t\t%.2f\n",bir_ogr.ogr_no,bir_ogr.ad_soyad,bir_ogr.sinif,bir_ogr.basarili_ders_say,bir_ogr.not_ort); } i++; } fclose(dosya2); } fclose(dosya); } return; } void bubble_sort(struct ogrenci gelen[]) { int i, j; struct ogrenci temp; for (i = 0; i < 49; i++) for (j = 0; j < 50 - i - 1; j++) if (gelen[j].not_ort > gelen[j + 1].not_ort) { temp = gelen[j]; gelen[j] = gelen[j + 1]; gelen[j + 1] = temp; } else if(gelen[j].not_ort == gelen[j + 1].not_ort) { if (gelen[j].basarili_ders_say > gelen[j + 1].basarili_ders_say) { temp = gelen[j]; gelen[j] = gelen[j + 1]; gelen[j + 1] = temp; } } return; } void sinifa_gore_listele(void) { FILE *dosya; char sinif_ad[3]; int i=0,j=0,k; long yer; struct ogrenci ogrenciler[50]= { 0,"","",0,0.0 }; struct ogrenci bir_ogr= { 0,"","",0,-1.0 }; if((dosya=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { printf("Sinifin adini giriniz.\n"); scanf("%s",sinif_ad); printf("Sira\tOgr no\tAd Soyad\tBasarili Ders Say\tNot Ort\n"); printf("----\t------\t--------\t-----------------\t-------\n"); fseek(dosya,0,SEEK_END); yer=ftell(dosya); yer/=sizeof(struct ogrenci); while(i<yer) { fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya); if(strcmp(bir_ogr.sinif,sinif_ad)==0) { if(bir_ogr.not_ort==0) { ogrenciler[j].ogr_no=bir_ogr.ogr_no; ogrenciler[j].basarili_ders_say=bir_ogr.basarili_ders_say; ogrenciler[j].not_ort=-1; for(k=0;k<24;k++) { ogrenciler[j].ad_soyad[k]=bir_ogr.ad_soyad[k]; } j++; } ogrenciler[j].ogr_no=bir_ogr.ogr_no; ogrenciler[j].basarili_ders_say=bir_ogr.basarili_ders_say; ogrenciler[j].not_ort=bir_ogr.not_ort; for(k=0;k<24;k++) { ogrenciler[j].ad_soyad[k]=bir_ogr.ad_soyad[k]; } j++; } i++; } bubble_sort(ogrenciler); k=0; for(i=49;i>=0;i--) { if(ogrenciler[i].sinif!=NULL && ogrenciler[i].not_ort!=0) { if(ogrenciler[i].not_ort==-1){ ogrenciler[i].not_ort=0; } printf("%d\t%d\t%s\t%d\t\t\t%.2f\n",++k,ogrenciler[i].ogr_no,ogrenciler[i].ad_soyad,ogrenciler[i].basarili_ders_say,ogrenciler[i].not_ort); } } fclose(dosya); } return; } int aralik_bul(int not) { int i; if(not<9.5) i=0; else if(not<19.5) i=1; else if(not<29.5) i=2; else if(not<39.5) i=3; else if(not<49.5) i=4; else if(not<59.5) i=5; else if(not<69.5) i=6; else if(not<79.5) i=7; else if(not<89.5) i=8; else if(not<101) i=9; return i; } void istatistik(void) { FILE *dosya; int toplam=0,ilk=90,son=99; int i=0; int j,indis; long yer; int ogr_sayisi[10]= { 0 }; float ogr_yuzdesi[10]; struct ogrenci bir_ogr= { 0,"","",0,0.0 }; if((dosya=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { printf("Not araligi\tOgrenci Sayisi\tOgrenci Yuzdesi\n"); printf("-----------\t--------------\t---------------\n"); fseek(dosya,0,SEEK_END); yer=ftell(dosya); yer/=sizeof(struct ogrenci); while(i<yer) { fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya); if(bir_ogr.not_ort!=0 || bir_ogr.ogr_no!=0) { indis=aralik_bul(bir_ogr.not_ort); ogr_sayisi[indis]=ogr_sayisi[indis]+1; } i++; } for(i=0;i<10;i++) { toplam=toplam+ogr_sayisi[i]; } j=0; while(j<10) { ogr_yuzdesi[j]=(float)ogr_sayisi[j]/toplam*100; j++; } printf("90-100\t\t\t"); for(i=9;i>0;i--) { ilk-=10; son-=10; printf("%d\t\t",ogr_sayisi[i]); printf("%.2f\n",ogr_yuzdesi[i]); printf("%d-%d\t\t\t",ilk,son); } printf("%d\t\t",ogr_sayisi[i]); printf("%.2f\n",ogr_yuzdesi[i]); fclose(dosya); } return; } void derse_gore_listele(void) { FILE *dosya; FILE *dosya2; int aranan_ders; int no,kod,not; int toplam=0,bulundu=0; int sayac=0; float ortalama; struct ogrenci bir_ogr= { 0,"","",0,0.0 }; if((dosya=fopen("notlar.dat","r"))== NULL) { printf("Notlar dosyasi acilamadi..\n\n"); } else { if((dosya2=fopen("ogrenciler.dat","rb+"))== NULL) { printf("Ogrenciler dosyasi acilamadi..\n\n"); } else { printf("Dersin kodunu giriniz.\n"); scanf("%d",&aranan_ders); printf("Ogr No\tAd Soyad\tSinif\tGecme Notu\n"); printf("------\t--------\t-----\t----------\n"); fscanf(dosya,"%d %d %d",&no,&kod,¬); while(!feof(dosya)) { if(aranan_ders==kod) { fseek(dosya2,(no-1)*sizeof(struct ogrenci),SEEK_SET); fread(&bir_ogr,sizeof(struct ogrenci),1,dosya2); printf("%d\t%s\t%s\t%d\n",bir_ogr.ogr_no,bir_ogr.ad_soyad,bir_ogr.sinif,not); toplam+=not; sayac++; bulundu=1; } fscanf(dosya,"%d %d %d",&no,&kod,¬); } if(bulundu==0) { printf("Okulumuzda boyle bir sinif yoktur.\n\n"); return; } ortalama=toplam/sayac; printf("Dersin genel not ortalamasi:%.2f",ortalama); fclose(dosya2); } fclose(dosya2); } return; } int main() { int gelen; do { gelen=menu(); switch(gelen) { case 1: ders_ekle(); break; case 2: kayit_sil(); break; case 3: ogr_listele(0); break; case 4: ogr_listele(1); break; case 5: ortalamaya_gore_listele(); break; case 6: sinifa_gore_listele(); break; case 7: istatistik(); break; case 8: derse_gore_listele(); break; } } while(gelen!=9); printf("Esen kalin.."); return 0; } |
Twitler yükleniyor... 5 saniye sonra
Bıdı bıdı bıdı bıdı dıdı dıdı dudu dudu hıdı hıdı hödü hödü yüklüyoruz öhüm öhüm bıdı bıdı vs vs... 6 nanosaniye önce
Yüklenmenin geç olmasının sebebi ben değilim, Twitter API'sinin yavaş olması. Gudu gudu hıdı hödö büdü büdü... 25697 asır önce
Ha tabi bunları okumuşsan, bu sitenin çok gizli bir özelliğini bulmuşsun demektir. ;) Tebrikler. Bu "sürpiz yumurta"yı bulduğunu bana da haber verir misin? Tıkla! 6 dinazor önce
int i;
if(not<9.5)
i=0;
else if(not<19.5)
i=1;
else if(not<29.5)
i=2;
else if(not<39.5)
i=3;
else if(not<49.5)
i=4;
else if(not<59.5)
i=5;
else if(not<69.5)
i=6;
else if(not<79.5)
i=7;
else if(not<89.5)
i=8;
else if(not<101)
i=9;
return i;
bu kadar uzun bir blok yerine notu 10′a bölmek daha mantıklı, sonra bölümü i değişkenine atarız… yinede güzel bir kaynak kod teşekkürler