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 |
why wa????#include<iostream.h> int main() { int a[493]={0}; int k=1; for(long i=1;i<=200;i++) { if(i<10) {a[k]=i;k++;} else if(i>=10&&i<100) { a[k]=i/10; k++; a[k]=i-(i/10)*10; k++; } else { a[k]=i/100; k++; a[k]=(i-(i/100)*100)/10; k++; a[k]=i-a[k-1]*10-a[k-2]*100; k++; } } int n; cin>>n; k=1; // for(i=1;i<=492;i++) // cout<<a[i]<<" "; for(i=1;i<=490;i++) { if(n<10&&(n==a[i])) {cout<<i<<endl;break;} else if(n<100&&(n==a[i]*10+a[i+1])) {cout<<i<<endl;break;} else if(n==a[i]*100+a[i+1]*10+a[i+2]) {cout<<i<<endl;break;} } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator