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 tcxgsy at 2006-09-09 14:17:09 on Problem 2998
#include<iostream>
using namespace std;
int tests;
 char name[101],n[100];
int num[11];
char ch[1000];
int a[3],b,re,total;


int main()
{
	  scanf("%d",&tests);
	while(tests--)
	{
    int pai=0;
	     getchar();
		gets(name);
		scanf("%d%s",&total,n);
		memset(num,0,sizeof(num));getchar();
		while(pai<total)
		{
			gets(ch);
		
		//	getchar();
			if(ch[0]=='+')
			{  for(int j=0;j<3;j++)
			          a[j]=0;
			    j=0;
				int len=strlen(ch);b=0;
				for(int i=2;i<=len;i++)
					if(ch[i]==' '||ch[i]=='\0')
					{   a[j]=b;
						j++;
					     b=0;
					}
					else 
					{  
						b=b*10+(ch[i]-'0');
					}
                for(i=a[0];i<=a[1];i=i+a[2])
				{
					re=i;
					while(re!=0)
					{
						b=re%10;
						num[b]++;
						re=re/10;
					
					}
	             pai++;
				}
			}
			else 
			{
				int len=strlen(ch);
			 	for(int i=0;i<len;i++)
				{ 
					num[ch[i]-'0']++;
					
				}
				pai++;
			}
			
		}
		printf("%s\n",name);
        printf("%d %s\n",total,n);
		for(int i=0;i<=9;i++)
			printf("Make %d digit %d\n",num[i],i);
	//	printf("In total %d digits\n",num[0]+num[1]+num[2]+num[3]+num[4]+num[5]+num[6]+num[7]+num[8]+num[9]);
       total=0;
	   for(i=0;i<=9;i++)
		   total+=num[i];
	   if(total>1)
	   printf("In total %d digits\n",total);
          else
	         printf("In total %d digit\n",total);
	}
	return 1;
}

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