2 solutions

  • 0
    @ 2025-7-15 11:07:16
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,m;
        while(cin>>n>>m,n||m)
        {
        	int s=0;
        	int k=0;
        	while(n&&m)//n和m不同时为0 
        	{
        		if(n%10+m%10+k>=10)//如果有进位 
        		{
        			k=1;
        			s++;
    			}
    			else//如果没有进位 
    			{
    				k=0;
    			}
    			n/=10,m/=10;//两个数省略个位 
    		}
    		cout<<s<<endl;
    	}
    	return 0;
    }

    Information

    ID
    2846
    Time
    1000ms
    Memory
    64MiB
    Difficulty
    9
    Tags
    # Submissions
    10
    Accepted
    6
    Uploaded By