Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

简单

Posted by fengchengyuan at 2009-11-03 10:43:12 on Problem 3340
#include<stdio.h>
#include<string.h>
char s1[100]="36?1?8";
char s2[100]="236428";
int num[100];
int ans;
int length;
/*

23??3?9
2341723
  */
power(int n)
{
int a;
int sum=1;
for(a=1;a<=n;a++)sum*=10;

return sum;


}


fun(int n)
{
if(n==length)return;


if(s1[n]!='?')
{	if(s1[n]>s2[n]){ans+=power(num[n]); }
else if(s1[n]==s2[n]){  fun(n+1);     }
else {  }

}

else
{

ans+=('9'-s2[n])*power(num[n]);

fun(n+1);

};



}

int main()
{int a;

while(gets(s1),strcmp(s1,"#")!=0)
	{	
gets(s2);
length=strlen(s1);
num[length-1]=0;
for(a=length-2;a>=0;a--)  num[a]=num[a+1]+(s1[a+1]=='?') ;
ans=0;
fun(0);
printf("%d\n",ans);
	}

}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator