题解 | #数位之和#
数位之和
https://ac.nowcoder.com/acm/problem/22199
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b=0;
cin>>a;
while(a){
b+=a%10;
a/=10;
}
cout<<b;
return 0;
}
数位之和
https://ac.nowcoder.com/acm/problem/22199
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b=0;
cin>>a;
while(a){
b+=a%10;
a/=10;
}
cout<<b;
return 0;
}
相关推荐