当前位置: 代码迷 >> 综合 >> [PAT][Basic level] 1016
  详细解决方案

[PAT][Basic level] 1016

热度:78   发布时间:2023-12-05 22:57:33.0

aside note: the array of strings ends of ‘\0’;

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
    char a[10],b[10];char d_a,d_b;cin>>a>>d_a>>b>>d_b;int sum_a = 0,sum_b = 0 ;for(int i = 0 ;i < strlen(a) ; i ++){
    if( a[i] == d_a){
    int num = d_a - '0';sum_a = sum_a*10+num;}}for(int i = 0 ;i < strlen(b) ; i ++){
    if( b[i] == d_b){
    int num = d_b - '0';sum_b = sum_b*10+num;}}cout<<sum_a+sum_b<<endl;//cout<<a<<" "<<d_a<<" "<<b<<" "<<d_b;return 0;
}
  相关解决方案