Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
7872 邓小龙 各个位数之和 C++ Accepted 0 MS 260 KB 518 2025-05-24 19:11:55

Tests(5/5):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n,cnt=0,s=0;//cnt:统计有几位数的 cin>>n; /* if(n==0){ cout<<1<<endl; return 0; } */ while(n){ cnt++; s+=n%10; n/=10; } //cout<<cnt<<endl; cout<<s<<endl; return 0; }