#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int main() { int counta = 0, countb = 0; int pa=0,pb=0; char a[10], b[10]; int da, db; scanf("%s %d %s %d", a, &da, b, &db); int i = 0; while (a[i] != '\0') { if (a[i] ==da+48 ) { counta++; } i++; } i=0; while (b[i] != '\0') { if (b[i] == db+48) { countb++; } i++; } if (counta != 0) { while (counta > 0) { counta--; pa = pa +da * pow(10,counta); } } if (countb != 0) { while (countb >0) { countb--; pb = pb +db * pow(10,countb); } } printf("%d", pa + pb); return 0; }
标签:pat,counta,countb,db,乙级,pb,int,pa,1016 From: https://www.cnblogs.com/Npc-Hb/p/17170390.html