部分A+B_1

正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA。例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6。

现给定A、DA、B、DB,请编写程序计算PA + PB

输入格式:

输入在一行中依次给出A、DA、B、DB,中间以空格分隔,其中0 < A, B < 1010

输出格式:

在一行中输出PA + PB的值。

输入样例1:

3862767 6 13530293 3

输出样例1:

399

输入样例2:

3862767 1 13530293 8

输出样例2:

0

==========================================================================
SRC:
#include <stdio.h>
#include <math.h> int main ()
{
int counterA, counterB,counterPA, counterPB ,i ;
char A[], B[] , XA, XB ;
unsigned long PA = , PB = ; counterA = ;
counterB = ;
counterPA = ;
counterPB = ; while ()
{
scanf ( "%c" , &XA ) ;
if ( XA == ' ' )
break ;
A[counterA++] = XA ; } scanf ( "%c" , &XA ) ;
printf ("XA:%c" , XA) ; // getchar () ; while ()
{
scanf ( "%c" , &XB ) ;
if ( XB == ' ' )
break ;
B[counterB++] = XB ; } scanf ( "%c" , &XB ) ;
printf ("XB:%c" , XB) ;
// getchar() ; for ( i = ; i < counterA ; i++ )
{
if ( XA == A[i] )
counterPA++ ;
}
for ( i = ; i < counterB ; i++ )
{
if ( XB == B[i] )
counterPB++ ; } counterA = (int)(XA-'') ;
counterB = (int)(XB -'') ; printf ("counterA = %d " , counterA ) ;
printf ("counterA = %d " , counterA ) ; for ( i = ; i < counterPA ; i++ )
{
PA += (unsigned long)(counterA*pow(, i ));
}
for ( i = ; i < counterPB ; i++ )
{
PB += (unsigned long)(counterB*pow( , i)) ;
} printf ("%uld" , (PA+PB) ) ; }
上一篇:python2.7安装matplotlib遇到的问题及解决方法


下一篇:[Python]round四舍五入精度缺失的解决