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> using namespace std; int main() { char c[7]; int n,i,t,k,j; long int sum; cin>>n; j=1; while (n--) { cin>>c; sum=0; k=strlen(c); for (i=0;i<=k;i++) { if (c[i]=='?') t=i; } for (i=0;i<k;i++) { if ((i%3==0)&&(i!=t)) sum+=(c[i]-48)*9; else if ((i%3==1)&&(i!=t)) sum+=(c[i]-48)*7; else if ((i%3==2)&&(i!=t)) sum+=(c[i]-48)*3; } switch (t%3) { case 0: for (i=9;i>=0;i--) if ((sum+i*9)%10==0) break; break; case 1: for (i=9;i>=0;i--) if ((sum+i*7)%10==0) break; break; case 2: for (i=9;i>=0;i--) if ((sum+i*3)%10==0) break; } c[t]=i+48; cout<<"Scenario #"<<j<<":"<<endl; cout<<c<<endl<<endl; j++; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator