1016. 部分A+B (这个版本仅供讨论)

来源:互联网 发布:宿迁网络电视台 编辑:程序博客网 时间:2024/06/16 13:29

1016. 部分A+B 

时间限制
100 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue

正整数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
#include <stdio.h>#include <conio.h>#include <math.h>double count();int main(){  double  A = 0, B = 0;  char ch = NULL;  A = count();  B = count();  printf("%.0lf", A + B);}double count(){  char ch = NULL,ch1 = NULL;  double count1 = 0;  int arr[10][2] = { { 0,-1 },{ 1,-1 },{ 2,-1 },{ 3,-1 },{ 4,-1 },{ 5,-1 },{ 6,-1 },{ 7,-1 },{ 8,-1 },{ 9,-1 } };  int i;  while (1)  {    ch = getche();    if (ch != ' ')      arr[ch-48][1]++;    else      break;  }  ch = getche();  ch1 = getche();  for (i = arr[ch - 48][1]; i >= 0; i--)    count1 += (pow(10, (double)i)*(double)arr[ch - 48][0]);  return count1;}

0 0
原创粉丝点击