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 ...
随机推荐
- I/O多路复用之select
1.什么是I/O多路复用 关于什么是I/O多路复用,在知乎上有个很好的回答,可以参考罗志宇前辈的回答. 这里记录一下自己的理解.我认为要理解这个术语得从两方面去出发,一是:多路是个什么概念?二是:复用 ...
- OpenCV——像素数据类型总结<摘>
1.Unsigned 8bits(一般的图像文件格式使用的大小)IplImage数据结构参数:IPL_DEPTH_8UCvMat数据结构参数:CV_8UC1,CV_8UC2,CV_8UC3,CV_8U ...
- 关于取数组地址的识记(&s+1,s+1,&s[0]+1)
#include <stdio.h> #include <malloc.h> int main() { ', 'o'}; ); printf(]); ]+); printf(] ...
- python中json的操作示例
先上一段示例 # -*- coding: cp936 -*- import json #构造一个示例数据,并打印成易读样式 j = {} j["userName"]="a ...
- Lucene学习总结之三:Lucene的索引文件格式(1)
Lucene的索引里面存了些什么,如何存放的,也即Lucene的索引文件格式,是读懂Lucene源代码的一把钥匙. 当我们真正进入到Lucene源代码之中的时候,我们会发现: Lucene的索引过程, ...
- [Zookeeper研究]一 Zookeeper技术简介
最近的项目中使用到了Zookeeper.Kafka以及Storm.仔细研究了一下,觉得这几个开源项目对于搞分布式的人来说是非常有用的,所以想把自己的一点心得体会总结一下,希望能对大家有所帮助. 首先从 ...
- 禁用谷歌字体解决WordPress访问速度过慢问题
这几天打开网站的时候发现突然变慢了,一直等待加载fonts.googleapis.com,搜索了一下发现很多wordpress网站都出现了 这种现象,原来是因为今日谷歌全线退出中国,貌似谷歌.Gmai ...
- static的用法解析
PHP中static变量的使用范围要更广一些,我们不仅可以在类,方法或变量前面添加static修饰符,我们甚至还能给函数内部变量添加static关键字.添加了static修饰符的变量即使在该函数执行完 ...
- Code First 创建数据库
最近在对以前学的知识做一个总结,EF 这块,Code First 是很重要的一部分,方便快捷创建模型. Code First有两种配置方式: DataAnnatation: [Table(&quo ...
- Qt制作Aero特效窗口
转载请注明链接与作者huihui1988 初学QT,边看书边自己做点小东西.最近突然心血来潮,想自己做个小巧点的,界面美观一点的备忘当桌面上.想了半天,发现VISTA/WIN7的Aero效果就不错,况 ...