字符数字转换
数位之和
https://ac.nowcoder.com/acm/contest/19305/1051
#include <iostream>
using namespace std;
int res;
int main(){
string s;
cin >> s;
for(int i = 0;i < s.size();i++) res += s[i] - '0';
cout << res;
}
字符减'0'转换为数字
数位之和
https://ac.nowcoder.com/acm/contest/19305/1051
#include <iostream>
using namespace std;
int res;
int main(){
string s;
cin >> s;
for(int i = 0;i < s.size();i++) res += s[i] - '0';
cout << res;
}
字符减'0'转换为数字
相关推荐