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 |
大家帮忙看一下 为什么总是runtime error#include <iostream> #include <cstring> using namespace std; int main() { char a[1000][10]={" "}; int n,i=0,j=0,k,m=0,b[1000][10]={0},sum=0,sum1=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++) for(j=0;j<10;j++) b[i][j]=-1; for(i=0;i<n;i++) { for(j=0;j<strlen(a[i]);j++) { if(a[i][j]!='?') b[i][j]=a[i][j]-'0'; else if(a[i][j]=='?') k=j; } sum=0; for(j=0;j<strlen(a[i]);j++) if(j!=k) { if(j%3==0) sum+=b[i][j]*9; if(j%3==1) sum+=b[i][j]*7; if(j%3==2) sum+=b[i][j]*3; } sum1=sum; for(m=0;m<10;m++) { sum=sum1; if(k%3==0) sum+=m*9; if(k%3==1) sum+=m*7; if(k%3==2) sum+=m*3; if(sum%5==0&&sum%2==0) {b[i][k]=m;break;} } cout<<"Scenario #"<<i+1<<":\n"; for(j=0;j<strlen(a[i]);j++) cout<<b[i][j]; cout<<"\n\n"; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator