|
|
back to boardwhy i get compilation error ???? Posted by Hany 30 Aug 2003 18:46 #include<stdio.h> #include<iostream.h> #include<string.h> char num[9]; int n; void plus() { int temp=(strlen(num)-1); while(num[temp]=='9') { num[temp]='0'; temp--; if(temp==-1) break; } if(temp!=-1) num[temp]++; } bool islucky() { int sum1=0,sum2=0; for(int c=0;c<n/2;c++) { sum1+=num[c]-48; sum2+=num[n-c-1]-48; } if(sum1==sum2) return true; else return false; } void main() { cin>>n; int count=1; char last[9]; for(int i=0;i<n;i++) { num[i]='0'; last[i]='9'; } num[i]=NULL; last[i]=NULL; while(strcmp(num,last)!=0) { if(islucky()==true) count++; plus(); } cout<<count<<endl; } |
|
|