U E D R , A S I H C RSS

StuPId/정진경

Source Code

#include <stdio.h>
#include <string.h>

int main()
{
	int n;
	int i, j, k;
	int sum, q, qk;
	char str[10];

	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%s\n", str);
		j=strlen(str)-1;
		k=9;
		sum=0;

		do{
			if(str[j]=='?'){
				q=j;
				qk=k;
			}else{
				sum+=k*(str[j]-'0');
			}
			k=(k==9)?3:((k==3)?7:9);
		}while(j-->0);

		if(qk==9){
			j=sum%10;
		}else{
			j=((sum%10)*qk)%10;
		}

		str[q]=j+'0';

		printf("Scenario #%d:\n%s\n\n", i, str);
	}

	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2011-08-30 09:34:28
Processing time 0.0078 sec