Coder

舒心、快乐,比什么都重要

1016 部分A+B (15 分)

// 题目不难,感觉变量定义的有点儿多了
#include <iostream> #include <cmath> using namespace std; int main(){ int i = 0, j = 0, ta = 0, tb = 0, suma = 0, sumb = 0; int A, Da, Pa, B, Db, Pb; cin >> A >> Da >> B >> Db; while (A != 0){ ta = A % 10; if (ta == Da){ suma += Da * pow(10,i); i++; } A /= 10; } while (B != 0){ tb = B % 10; if (tb == Db){ sumb += Db * pow(10,j); j++; } B /= 10; } cout << suma + sumb << endl; return 0; }

 

posted @ 2019-04-21 22:20  H123K  阅读(146)  评论(0编辑  收藏  举报