1016部分A+B
来源:互联网 发布:ipad清理缓存软件 编辑:程序博客网 时间:2024/04/29 03:00
正整数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<iostream>#include<string>#include<math.h>using namespace std;//string add(string str1,string str2){//reverse(str1.begin(),str1.end());//reverse(str2.begin(),str2.end());//if(str1.length() < str2.length()){//int carry = 0;//for(int i = 0;i < str1.length();i++){//if()//}//}//}int main(){string str_A,str_B;char a,b;for(;cin>>str_A>>a>>str_B>>b;){int count_A = 0,count_B = 0;for(int i =0;i < str_A.length();i++){if(str_A[i] == a){count_A++;}}for(int j =0;j < str_B.length();j++){if(str_B[j] == b){count_B++;}}long long int sum = 0;for(int i = 0;i<count_A;i++){sum+= pow(10,i)*(a - '0');}for(int i = 0;i < count_B;i++){sum+= pow(10,i)*(b - '0');}cout<<sum<<endl;}return 0 ;}
0 0
- 1016 部分A+B
- 1016部分A+B
- 1016 部分a+b
- 1016:部分A+B
- 1016 部分A+B (15)
- PAT-1016 部分A+B
- 部分A+B,PAT,1016
- PAT 1016部分A+B
- PAT 1016 部分 A+B
- PAT basic 1016 :部分A+B
- ZJU PAT 1016 部分A+B
- 1016_部分A+B (15)
- PAT_乙级 1016 部分A+B
- PAT 乙级 1016 部分A+B (15)
- PAT BASIC 1016 部分A+B
- PAT乙级1016 部分A+B
- PAT——1016部分A+B
- 1016部分A+B(模拟)
- SUMO使用教程(六)
- EditText字数限制
- 没有躲过的坑--deprecated关键字
- vbs自学(一)
- Selinux在Enforcing mode切到root
- 1016部分A+B
- NYOJ 1185 最大最小值 (线段树 & 区间最值查询)
- PHP类延迟加载机制原理
- 学习笔记-选择排序 14/12/29
- SUMO使用教程(七)
- ruby on rails环境搭建
- 如何使用sendEmail发送邮件
- [NOIP 2009]HackSon的趣味题 数论
- oracle客户端安装