Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么会错??#include <iostream> #include <string> #include <stdlib.h> using namespace std; int number(char a) { if (a=='0') return 0; if (a=='1') return 1; if (a=='2') return 2; if (a=='3') return 3; if (a=='4') return 4; if (a=='5') return 5; if (a=='6') return 6; if (a=='7') return 7; if (a=='8') return 8; if (a=='9') return 9; if (a=='a') return 10; if (a=='b') return 11; if (a=='c') return 12; if (a=='d') return 13; if (a=='e') return 14; if (a=='f') return 15; } void main() { int a; for (a=2992;a<=9999;a++) { int count1=0,count2=0; char str1[5],str2[5]; itoa(a,str1,10); itoa(a,str2,16); int i,j; for (i=0;i<strlen(str1);i++) count1+=number(str1[i]); for (j=0;j<strlen(str2);j++) count2+=number(str2[j]); if (count1==count2) cout<<a<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator