• <input id="auww4"></input>
  • <input id="auww4"><acronym id="auww4"></acronym></input>
  • <input id="auww4"><u id="auww4"></u></input>
    <object id="auww4"><acronym id="auww4"></acronym></object>
    <menu id="auww4"></menu><input id="auww4"><u id="auww4"></u></input>
    <input id="auww4"><u id="auww4"></u></input>
  • F.A.Q
    Hand In Hand
    Online Acmers
    Forum | Discuss
    Statistical Charts
    Problem Archive
    Realtime Judge Status
    Authors Ranklist
     
         C/C++/Java Exams     
    ACM Steps
    Go to Job
    Contest LiveCast
    ICPC@China
    Best Coder beta
    VIP | STD Contests
    Virtual Contests
        DIY | Web-DIY beta
    Recent Contests
    Author ID 
    Password 
     Register new ID

    Re:AC附上一組新的測試數組

    Posted by 李佳鵬 at 2014-09-15 19:51:34 on Problem 1003
    (616)  


    #include<stdio.h>
    
    int main()
    {
    	int flag;
    	while(scanf("%d", &flag) != EOF)
    	{
    		char a[999], b[999];
    		int sum[1000] ;
    		int count;
    		for(int i = 0; i < flag; i++)
    			{
    				for(int l = 0; l <= 999; l++)
    				{
    					a[l] = 'a' ; 
    					b[l] = 'a';
    					sum[l] = 0;
    				}
    				scanf("%s %s", a, b);
    			     for(int j = 998; j >= 0; j--)
    				{
    					if(a[j]	!= 'a')
    					{
    						j--;
    			        		for(int k = 998; k > 0; k--)
    						{
    							 	if(b[k] != 'a')
    								{
    									k--;
    									if( k > j)
    									{ 
    										count  = k;
    										while(j >= 0)
    										{
    											sum[k] += b[k] + a[j] - '0' - '0';
    											if(sum[k] >= 10)
    											{
    												int swap = sum[k];
    												sum[k] = sum[k] % 10; 
    												int nom = k - 1;
    												sum[nom] += swap / 10; 
    											}
    											k--;
    											j--;
    										}
    										for(int n = 0; n <= k; n++)
    											sum[n] += b[n] - '0';
    									}
    									else 
    									{
    										count = j;
    										while(k >= 0)
    										{
    											sum[j] += b[k] + a[j] - '0' - '0';
    											if(sum[j] >= 10)
    											{
    												int swap = sum[j];
    												if(k == 0 && j == 0){}
    												else
    												sum[j] = sum[j] % 10; 
    												int nom = j - 1;
    												sum[nom] += swap / 10; 
    											}
    											k--;
    											j--;
    										}
    										for(int n = 0; n <= j; n++)
    											sum[n] += a[n] - '0';
    									}
    								}		
    					        }
                                            }
    				}	
    				int num = 0;
    				printf("Case %d\n", i + 1);
    				printf("%s + %s = ", a, b);
    				while(num <= count)
    				{
    					printf("%d",sum[num]);
    					num++;
    				}
    				printf("\n\n");
    			}
    	}
    	return 0;
    	
    }

    Followed by:


    Post your reply here:

    Author ID
    Password
    Title
    Content  
     
    Hangzhou Dianzi University Online Judge 3.0
    Copyright © 2005-2020 HDU ACM Team. All Rights Reserved.
    Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
    Total 0.000000(s) query 4, Server time : 2020-11-09 02:29:35, Gzip enabled
    棋牌