J - A + B Problem II(第二季水)
Description
Input
Output
Sample Input
Sample Output
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string.h>
using namespace std;
int f(char a[],char b[],int s[])
{
int m=strlen(a),n=strlen(b),i,x[],y[],k;
memset(x,,sizeof(x));
memset(y,,sizeof(y));
k=max(m,n);
if(m==k){
for(i=;i<m;i++)x[i]=a[i]-'';
for(i=m-;i>=m-n;i--)y[i]=b[n-m+i]-'';
}
if(n==k){
for(i=;i<n;i++)y[i]=b[i]-'';
for(i=n-;i>=n-m;i--)x[i]=a[m-n+i]-'';
}
s[]=;
for(i=;i<k+;i++)s[i]=x[i-]+y[i-];
for(i=k;i>=;i--){
if(s[i]>){
s[i]-=;
s[i-]++;
}
}
return k;
}
int main()
{
char a[],b[];
int n,k=;
cin>>n;
while(k<=n){
cin>>a>>b;
cout<<"Case "<<k<<":"<<endl;
cout<<a<<" + "<<b<<" = ";
int s[];
int t=f(a,b,s);
for(int i=;i<t+;i++){
if(s[]==&&i==)continue;
cout<<s[i];
}
if(k!=n)cout<<endl;
cout<<endl;
k++;
}
//system("pause");
return ;
}
格式错误好几次
J - A + B Problem II(第二季水)的更多相关文章
- F - The Fun Number System(第二季水)
Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...
- D - Counterfeit Dollar(第二季水)
Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...
- A - 高精度(大数)N次方(第二季水)
Description Problems involving the computation of exact values of very large magnitude and precision ...
- Y - Design T-Shirt(第二季水)
Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...
- N - Robot Motion(第二季水)
Description A robot has been programmed to follow the instructions in its path. Instructions for the ...
- S - 骨牌铺方格(第二季水)
Description 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...
- R - 一只小蜜蜂...(第二季水)
Description 有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数. 其中,蜂房的结构如下所示. ...
- E - Number Sequence(第二季水)
Description A single positive integer i is given. Write a program to find the digit located in the p ...
- I - Long Distance Racing(第二季水)
Description Bessie is training for her next race by running on a path that includes hills so that sh ...
随机推荐
- Xcode的代码片段快捷方式-Code Snippet Library(代码片段库)
最近换了新电脑,装上Xcode敲代码发现很多以前攒的Code Snippet忘记备份了,总结了一下Code Snippet的设置方法,且行且添加,慢慢积累吧. 如下图: Title - Code ...
- Java实现的 线程池
由于最近开始学习java,用到了线程池,按照之前c++的写法写出此java版的线程池 TaskRunnale实现相关任务的接口,具体要实现什么任务在相应的run函数中实现. package threa ...
- CAN总线
1.CAN(controller area network) LAN(local area network)局域网 2.CAN等通信协议的开发,使多种LAN通过网关进行数据交换得以实现.如应用在汽车电 ...
- TextView之一:子类的常用属性
TextView常见的子类包括EditText,Button,CheckBox, RadioButton等. 1.EditText EditText继承自TextView,因此TextView所有属性 ...
- Radar Installation(POJ 1328 区间贪心)
Radar Installation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 68578 Accepted: 15 ...
- MVC 中使用uploadify上传图片遇到的蛋疼问题
MVC 中使用uploadify上传图片遇到的蛋疼问题 初次使用uploadify上传图片,遇到了一些比较纠结的问题,在这里和大家分享下,有不对的地方还望大神多多指教,希望对刚接触的朋友有所帮助,文采 ...
- NET Core的知识
NET Core的基础知识补遗 阅读目录 前言 在.NET Core之前 在.NET Core起步 .NET Core 1.0 .NET平台 开发环境 FAQ 写在最后 回到目录 前言 .NET Co ...
- Typecho 代码阅读笔记(二) - 数据库访问
转载请注明出处:http://blog.csdn.net/jh_zzz 这一块比较复杂,我还没有完全理解为什么要把 SQL 语句的组装搞这么复杂. 从一个普通皮肤页面开始 themes/default ...
- hdu 1500 Chopsticks
http://acm.hdu.edu.cn/showproblem.php?pid=1500 dp[i][j]为第i个人第j个筷子. #include <cstdio> #include ...
- App 推荐:Spotify
之前一直用网易云音乐听歌,后来因为沸沸扬扬的 XCode 注入病毒事件,就把它卸了(无奈脸=.=) 对比国内其它音乐App,私心觉得网易云音乐还是不错的.没有很多花里胡哨的装饰,里面的歌单做的也还算精 ...