题目链接:http://ac.jobdu.com/problem.php?pid=1003

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
// 1003 A+B.cpp
// Jobdu
//
// Created by PengFei_Zheng on 2017/4/14.
// Copyright © 2017年 PengFei_Zheng. All rights reserved.
// #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cmath> using namespace std; char a[],b[];
int num1,num2; int main(){
while(scanf("%s%s",a,b)!=EOF){
int lena = (int)strlen(a);
int lenb = (int)strlen(b);
num1 = num2 = ;
int size1 = ;
int size2 = ;
bool flag1 = (a[]>=''&&a[]<='') ? true : false;
bool flag2 = (b[]>=''&&b[]<='')? true : false;
for(int i = lena - ; i >= ; i--){
if(a[i]>='' && a[i]<=''){
num1+=(a[i]-'')*pow(,size1);
size1++;
}
}
for(int i = lenb - ; i >= ; i--){
if(b[i]>='' && b[i]<=''){
num2+=(b[i]-'')*pow(,size2);
size2++;
}
}
if(flag1&&flag2) printf("%d\n",num1+num2);
else if(flag1 && !flag2) printf("%d\n",num1-num2);
else if(flag2 && !flag1) printf("%d\n",num2-num1);
else if(!flag1 && !flag2) printf("%d\n",-num1-num2);
}
}
/**************************************************************
Problem: 1003
User: zpfbuaa
Language: C++
Result: Accepted
Time:0 ms
Memory:1608 kb
****************************************************************/

题目1003:A+B(按逗号分隔的A+B)的更多相关文章

  1. 题目1003:A+B

    题目1003:A+B 时间限制:1 秒内存限制:32 兆 题目描述: 给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开. 现在请计算A+B的结果,并以正常形式 ...

  2. 九度OJ题目1003:A+B

    while(cin>>str1>>str2)就行了,多简单,不得不吐槽,九度的OJ真奇葩 题目描述: 给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号", ...

  3. 题目1003:A+B(字符串转数字)

    问题来源 http://ac.jobdu.com/problem.php?pid=1003 问题描述 每次给你两个数,数的形式是每三位有一个间隔符',',计算两数之和. 问题分析 两个问题,一.如何读 ...

  4. shell练习--PAT题目1003:我要通过!(成功案例)

    “答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于 PAT 的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”. 得到“答案正确”的条件是: ...

  5. 题目1003:A+B ---c_str(),atoi()函数的使用;remove , erase函数的使用

    #include<stdio.h> #include<stdlib.h> int sw(char *a){ ,c=; while(a[i]){ ') c=c*+a[i]-'; ...

  6. HDU OJ Max sum 题目1003

     #include <iostream> #include<stdio.h> #include<stdlib.h> using namespace std; i ...

  7. 九度oj 1003 A+B 2010年浙江大学计算机及软件工程研究生机试真题

    题目1003:A+B 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:12812 解决:5345 题目描述: 给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号",&qu ...

  8. 九度oj 1003

    前几天开刷九度oj,准备把做的题都放上,先放1003 题目1003:A+B             时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:16923 解决:7029 题目描述: 给 ...

  9. SCNU 2015ACM新生赛初赛【1001~1011】个人解题思路

            题目1001:       大意:已知$n$个角色,$m$种怪物种族,$k$个怪物,给出一组角色编号,编号$P_{i}$的角色能肝死编号$i$的怪物,对于给定的一组怪物编号,为了打通关 ...

随机推荐

  1. C# 一个多层循环中,break一次能跳出几个循环?

    public class BreakTest { public static void main(String[] args) { ; x<; x++) { ; y<; y++) { ; ...

  2. thinkphp中的AJAX返回ajaxReturn()

    系统支持任何的AJAX类库,Action类提供了ajaxReturn方法用于AJAX调用后返回数据给客户端.并且支持JSON.XML和EVAL三种方式给客户端接受数据,通过配置DEFAULT_AJAX ...

  3. linux内置软件安装命令

    yum -y install epel-release

  4. unity3d 获取游戏对象详解

    原文地址:http://www.xuanyusong.com/archives/2768 我觉得Unity里面的Transform 和 GameObject就像两个双胞胎兄弟一样,这俩哥们很要好,我能 ...

  5. VS2010 工程设置

       本篇文章的主要内容转载自 http://blog.csdn.net/waitforfree/article/details/8622059 ,感谢博主的辛苦劳动.此处,对比较重要的部分,进行进一 ...

  6. 安卓开发笔记——打造万能适配器(Adapter)

    为什么要打造万能适配器? 在安卓开发中,用到ListView和GridView的地方实在是太多了,系统默认给我们提供的适配器(ArrayAdapter,SimpleAdapter)经常不能满足我们的需 ...

  7. 代码记录——phase16,block36

    36*36 -2,-2扩展 代码有问题,有时能运行有时报错. HRESULT RotateZoom(PBYTE pbSrc,int iWidth,int iHeight,double dbRotate ...

  8. GDAL------加载Shapefile文件

    代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...

  9. POJ1159——Palindrome

    Palindrome Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 53647   Accepted: 18522 Desc ...

  10. SpringMVC由浅入深day02_8json数据交互

    8 json数据交互 8.1 为什么要进行json数据交互 json数据格式在接口调用中.html页面中较常用,json格式比较简单,解析还比较方便. 比如:webservice接口,传输json数据 ...