1016. Part A + B (15), OP qdp1016b
1016. Part A + B (15)
The "DA (one-digit integer) Section of positive integer A is defined as A new integer PA consisting of all DA in. For example, given A = 3862767, DA = 6, the "6 Part" PA of A is 66, because A has 2 6.
If A, DA, B, and DB are specified, write A program to calculate PA + PB.
Input Format:
Enter A, DA, B, and DB in one row, and separate them with spaces. 0 <A, B <1010.
Output Format:
Output the PA + PB value in a row.
Input Example 1:
3862767 6 13530293 3
Output Example 1:
399
Input Example 2:
3862767 1 13530293 8
Output Example 2:
0
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char ta[10],tb[10]; 6 int a,b,i,j; 7 long long suma=0,sumb=0; 8 scanf("%s%d%s%d",ta,&a,tb,&b); 9 for(i=0;i<strlen(ta);i++)10 {11 if(ta[i]-'0'==a)12 suma=suma*10+a;13 }14 for(i=0;i<strlen(tb);i++)15 {16 if(tb[i]-'0'==b)17 sumb=sumb*10+b;18 }19 printf("%lld\n",suma+sumb);20 return 0;21 }