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 |
水过100~~~~~~~~~~~!附代码,一次A!#include<stdio.h> #include<string.h> int main() { int obj[3] = {9, 3, 7}; char str[10]; int i, k; int n, count; int sum, p; fscanf(stdin, "%d", &n); for (p=1; p<=n; p++) { sum = 0; fscanf(stdin, "%s", str); k = strlen(str); for (i=k-1; i>=0; i--) { if (str[i] == '?') { count = i; } else { sum += ((str[i]-'0') * obj[(k-i+2)%3]); } } for (i=0; i<=9; i++) if ((sum + i * obj[(k-count+2)%3]) %10 == 0) { str[count] = i + '0'; } printf("Scenario #%d:\n", p); printf("%s\n\n", str); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator