1 solutions

  • 0
    @ 2025-3-3 16:33:59

    C :

    #include<stdio.h>   
    
    int main(){  
    	int x;
    	scanf("%d",&x);
    	
    	int b = x / 100;
    	int s = x / 10 % 10;
    	int g = x % 10;
    	
    	printf("%d",b+s+g);
    	
    	return 0; 
    } 
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int a,b,c,x,s;
    	cin>>x;
    	a=x/100;
    	b=x/10%10;
    	c=x%10;
    	s=a+b+c;
    	cout<<s<<endl;
    	
    	
    }
    

    Python :

    n=int(input())
    a=n//100
    b=n//10%10
    c=n%10
    print(a+b+c)
    
    • 1

    【入门】求任意三位数各个数位上数字的和

    Information

    ID
    10848
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By