Submission #996416
Source Code Expand
#include <stdio.h> int ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return -1; } } char S[5]; int K; int main(){ scanf("%d",&K); scanf("%s",&S); if(K!=0){ if(strlen(S)==2){ if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));} else{printf("%d¥n",ctoi(S[1]));} } else{printf("%d¥n",ctoi(S[0]));} } else{printf("%d¥n",atoi(S));} return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Problem where Commas Separate Digits |
User | Bwambocos |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 588 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:24:14: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[5]’ [-Wformat=] scanf("%s",&S); ^ ./Main.cpp:27:12: error: ‘strlen’ was not declared in this scope if(strlen(S)==2){ ^ ./Main.cpp:34:27: error: ‘atoi’ was not declared in this scope else{printf("%d¥n",atoi(S));} ^ ./Main.cpp:23:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&K); ^ ./Main.cpp:24:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",&S); ^