8 条题解
-
0
Guest
- 1
信息
- ID
- 14
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- 递交数
- 193
- 已通过
- 128
- 上传者
因为是四位数,位数确定,所以可以用 char
来写。
#include<bits/stdc++.h>
using namespace std;
char a,b,c,d;
int main(){
cin>>a>>b>>c>>d;
cout<<a-'0'+b-'0'+c-'0'+d-'0';
return 0;
}
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c,d,e,f; cin>>a; b=a/1000; c=a/100%10; d=a/10%10; e=a%10; f=b+c+d+e; cout<<f; return 0; }
#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,d,e,f;
cin>>a;
b=a/1000;
c=a/100%10;
d=a/10%10;
e=a%10;
f=b+c+d+e;
cout<<f;
return 0;
}
注册一个 PYYG 通用账户,您就可以在我们提供的所有在线评测服务上提交代码、参与讨论。