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;
    }
    • 0
      @ 2025-7-11 10:58:14
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int k=0;
      	for(int i=1;i<=999;i++){
      		int n,m;
      		cin>>n>>m;
      		int g=n%10;
      		int s=n/10%10;
      		int b=n/100;
      		int g1=m%10;
      		int s1=m/10%10;
      		int b1=m/100;
      		if(n==0&&m==0){
      			return 0;
      		}
      		if(g+g1>=10){
      			s++;
      			k++;
      		}
      		if(s+s1>=10){
      			b++;
      			k++;
      		}
      		if(b+b1>=10){
      			k++;
      		}
      		cout<<k<<endl;
      		k=0;
      		g=0;
      		g1=0;
      		s=0;
      		s1=0;
      		b=0;
      		b1=0;
      	}
      	return 0;
      }
      
      • 1

      Information

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