1503 Integer Inquiry

Integer Inquiry
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 5360   Accepted: 2131

Description
One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.
``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)

Input
The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative).

The final input line will contain a single zero on a line by itself.

Output
Your program should output the sum of the VeryLongIntegers given in the input.

Sample Input

 

Sample Output

 

Source
East Central North America 1996

 *************************************************************************************************

*********************************************************************************************

  • Source Code
    #include<stdio.h>
    #include<string.h>
    
    int main()
    {
    	int a[200];
        char b[200];
    	int i;
    	
    	for(i=0;i<200;i++)
    		a[i]=0;
    	while(1)
    	{
    		scanf("%s",b);
    		if(strcmp(b,"0")==0)
    			break;
    		strrev(b);
    		for(i=0;b[i]!='/0';i++)
    			a[i]+=(b[i]-'0');
    	}
    	for(i=1;i<200;i++)
    	{
    		a[i]+=a[i-1]/10;
    		a[i-1]=a[i-1]%10;
    	}
       for(i=199;a[i]==0;i--);
    	for(i;i>=0;i--)
    		printf("%d",a[i]);
      printf("/n");
    		
    	return 0;
    }
    
    

     

    370370367037037036703703703670

     

    123456789012345678901234567890
    123456789012345678901234567890
    123456789012345678901234567890
    0
  • 你可能感兴趣的:(1503 Integer Inquiry)