|
|
вернуться в форумthat is not like a computer in my code? #include<stdio.h> #include<string.h> int comp(char *pen,char *peng) { int i; for(i=0;i<strlen(pen);i++) if(pen[i]!=peng[i]) return 0; return 1; } int main() { int i,a=0,b=0,c=0,n; char pen[3][10]={"Emperor","Little","Macaroni"},peng[20]; scanf("%d",&n); for(i=0;i<n;i++) { fflush(stdin); gets(peng); if(comp(pen[0],peng)) ++a; if(comp(pen[1],peng)) ++b; if(comp(pen[2],peng)) ++c; } if(a>b&&a>c) printf("Emperor Penguin"); if(b>a&&b>c) printf("Little Penguin"); if(c>b&&c>a) printf("Macaroni Penguin"); return 0; } Re: that is not like a computer in my code? figured out, you need to clear the buffer perverted by scanf ("% * [^ \ n] "); and used to enter the scanf ("% s ", peng); |
|
|