标签:string strong lazy span a+b stream pytho int namespace
今天脑子有点不太清醒,先做这个,明天做1015(偷懒了,这个是个水题)
1 #include<iostream> 2 3 using namespace std; 4 5 int main() { 6 string a, b; 7 char da, db; 8 int pa = 0, pb = 0; 9 cin >> a >> da >> b >> db; 10 for (int i = 0; i < a.size(); i++) { 11 if (a[i] == da) { 12 pa = pa * 10 + (da - ‘0‘); 13 } 14 } 15 for (int i = 0; i < b.size(); i++) { 16 if (b[i] == db) { 17 pb = pb * 10 + (db - ‘0‘); 18 } 19 } 20 cout << pa + pb; 21 return 0; 22 }
1 def count(num, d): 2 k = 0 3 for i in num: 4 if i == d: 5 k += 1 6 if k == 0: 7 return 0 8 else: 9 return int(k * d) 10 11 a, da, b, db = input().split() 12 print(count(a, da) + count(b, db))
很水没啥好说的
标签:string strong lazy span a+b stream pytho int namespace
原文地址:https://www.cnblogs.com/SCP-514/p/13227867.html