cheapwine פורסם 2004 בנובמבר 25 Share פורסם 2004 בנובמבר 25 http://www.cs.biu.ac.il/~kalechm/c_04/cf2_math.rtfזה התרגיל זה הפתרון אוקיי.....אני מריץ את הקודק הראשון....הוא לא טוב הוא במקום להוריד 10 מהאסקי מוריד פחות. void code_a(); void code_b(); void code_c(); void code_d(); void decode_a(); void decode_b(); void decode_c(); int main () { int codec; char tav; //printf("enter the codec that u want\n"); scanf("%d",&codec); while (codec<1 || codec>8) { printf("Range error\n"); scanf("%d",&codec); } scanf("%c",&tav); while (codec!=8) { switch (codec) { case 1 :code_a(); break; case 2 :code_b(); break; case 3 :code_c(); break; case 4 :code_d(); break; case 5 :decode_a(); break; case 6 :decode_b(); break; case 7 :decode_c(); break; } //printf("enter the codec that u want\n"); scanf("%d",&codec); while ((codec<1) || (codec> 8)) { printf("Range error\n"); scanf("%d",&codec); } scanf("%c",&tav); } return 0; } void code_a() { char tav; //printf("enter the tav u want\n"); scanf("%c",&tav); while (tav!='@') { if ((tav<42) && (tav>32)) { tav='~'-(10-(tav-'!')); printf("%c",tav); } else { if (tav<=126 && tav>=43) { tav=tav-10; printf("%c",tav); } else { printf("Input error");/* while (tav!='@') { scanf("%c",&tav); }*/ } } //printf("enter the tav u want"); scanf("%c",&tav); } printf("\n"); } void code_b() { char tav; //printf("enter the tav u want"); scanf("%c",&tav); while (tav!='@') { if (tav>='A' && tav<='Z') { tav='Z'-tav+1; printf("%c",tav); } else { if (tav>='a' && tav<='z') { tav='z'-tav+1; printf("%c",tav); } else { printf("Input error\n"); while (tav!='@') { scanf("%c",&tav); } } } if (tav!='@') { //printf("enter the tav u want"); scanf("%c",&tav); } } } void code_c() { char tav; int num,mesakem,hezka; //printf("enter the tav u want"); scanf("%c",&tav); while (tav!='@'); { num=tav;mesakem=0;hezka=1; while (num!=0); { mesakem += (num%8)*hezka; hezka = hezka*10; num=num/8; } printf("%d ",mesakem); //printf("enter the tav u want"); scanf("%c",&tav); } } void code_d() { char tav; int num,temp,mesakem,i,azeret,mesakemm; //printf("enter the tav u want"); scanf("%c",&tav); mesakemm=0; while (tav!='@') { num=tav; mesakem=0; while (num>0) { temp=(num%10); azeret=1; for (i=1;i<=temp;i++) { azeret=azeret*i; } mesakem+=mesakem*azeret; num=(num/10); } mesakemm+=mesakem; //printf("enter the tav u want"); scanf("%c",&tav); } printf("%d",mesakemm); } void decode_a() { char tav; //printf("enter the tav u want"); scanf("%c",&tav); while (tav!='@') { if ((tav<127) && (tav>117)) { tav='~'+(10-(tav-'!')); printf("%c",tav); } else { if (tav<=116 && tav>=33) { tav+=10; printf("%c",tav); } else { printf("Input error\n"); while (tav!='@') { scanf("%c",&tav); } } } if (tav!='@') { //printf("enter the tav u want"); scanf("%c",&tav); } } } void decode_b() { char tav; //printf("enter the tav u want"); scanf("%c",&tav); while (tav!='@') { if (tav>='A' && tav<='Z') { tav='Z'-tav+1; printf("%c",tav); } else { if (tav>='a' && tav<='z') { tav='z'-tav+1; printf("%c",tav); } else { printf("Input error\n"); while (tav!='@') { scanf("%c",&tav); } } } if (tav!='@') { //printf("enter the tav u want"); scanf("%c",&tav); } } } void decode_c() { // char tav; int hezka,mesakem,num =0; //printf("enter the tav u want"); scanf("%d",num); while (num!=0) { hezka=1; mesakem=0; while (num>0) { mesakem=mesakem+(num%10)*hezka; hezka=hezka*8; num=num/10; } printf("%c ",mesakem); //printf("enter the tav u want"); scanf("%d",num); } }תודה מראש[/left][/sup]#include <stdio.h> קישור לתוכן שתף באתרים אחרים More sharing options...
Recommended Posts
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.