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 <stdio.h> #include <string.h> int main () { char str[10]; int num[10]; int u; int i; int x; int sum; int j=1; int n;int len; scanf ("%d",&n); while (n--) { int flag=1; sum=0; scanf("%s",str); len=strlen(str); for(i=len;i>=1;i--) { if (flag%3==1) num[i]=9; if (flag%3==2) num[i]=3; if (flag%3==0) num[i]=7; flag++; } for (i=0;i<len;i++) { if (str[i]=='?') {x=num[i+1];} else sum=sum+(str[i]-'0')*num[i+1]; } for (i=0;i<=9;i++) {if ((sum+x*i)%10==0) {u=i; break;} } printf("Scenario #%d:\n",j); for (i=0;i<len;i++) { if (str[i]!='?') printf("%c",str[i]); else printf("%d",u);} printf("\n\n"); 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