#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
string A, B;
char Da, Db;
int cnt1=0, cnt2=0;
int res1=0, res2=0;
cin >> A >> Da >> B >> Db;
for(int i = 0; i < A.length(); i ++){
if( A[i] == Da){
cnt1++;
}
}
for(int i = 0; i < B.length(); i ++){
if( B[i] == Db){
cnt2++;
}
}
for(int i = 0; i < cnt1; i++){
res1 += pow(10,i) * (Da-'0');
}
for(int i = 0; i < cnt2; i++){
res2 += pow(10,i) * (Db-'0');
}
cout << res1 + res2;
return 0;
}
C语言程序时合计-1016 部分A+B
最新推荐文章于 2025-03-20 19:17:35 发布
本文介绍了一种使用C++编程语言实现的字符计数和数值转换的方法。通过读取两个字符串和两个字符,程序计算每个字符串中特定字符的出现次数,并将这些次数转换为数值进行相加。此代码利用了C++标准库中的iostream、string和math.h,展示了基本的字符串操作和数学函数应用。
797

被折叠的 条评论
为什么被折叠?



