原題:
Calculate a + b
Input
The input will consist of a series of pairs of integers a and b,
separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum
of a and b in one line,and with one line of utput for each line in input.
Sample Input
1 5
Sample Output
6
Hint
Use + operator
| |
#include<iostream>
#include<string>
using namespace std;


int main()


{
string a,b;
char *c = NULL;
long a_len = 0,b_len = 0,c_len=0,min_len;
int one_bit = 0;
bool flag = false;
while(cin>>a>>b)

{
if (a[0]!='-'&&b[0]!='-')

{
a_len = a.length();
b_len = b.length();
c_len = (a_len>b_len?a_len:b_len)+1;
min_len = a_len<b_len?a_len:b_len;
c = new char[c_len+1];
c[c_len] = '\0';
c[0] = 'A';
while(min_len>0)

{
one_bit=int(a[a_len-1])+int(b[b_len-1])-96;
if(flag)
one_bit++;
if(one_bit>9)

{
one_bit -= 10;
flag = true;
}
else
flag = false;
c[c_len-1] = char(one_bit+48);
one_bit = 0;
c_len--;
min_len--;
a_len--;
b_len--;
}
if(a_len==0)

{
while(b_len>0)

{
one_bit=int(b[b_len-1])-48;
if(flag)
one_bit++;
if(one_bit>9)

{
one_bit -= 10;
flag = true;
}
else
flag = false;
c[c_len-1] = char(one_bit+48);
one_bit = 0;
c_len--;
b_len--;
}
}

if(b_len==0)

{
while(a_len>0)

{
one_bit=int(a[a_len-1])-48;
if(flag)
one_bit++;
if(one_bit>9)

{
one_bit -= 10;
flag = true;
}
else
flag = false;
c[c_len-1] = char(one_bit+48);
one_bit = 0;
c_len--;
a_len--;
}
}
if(flag)
c[0] = '1';
}

if (flag)
cout<<c<<endl;
else
cout<<++c<<endl;
flag = false;
c = NULL;
}

return 0;
}這是當(dāng)時(shí)提交的源程序,本以為要考慮負(fù)數(shù)的,原來不用......
同濟(jì)大學(xué)的 Online Judge -http://acm.tongji.edu.cn/
浙江大學(xué)的 Online Judge -http://acm.zju.edu.cn/
北京大學(xué)的 Online Judge -http://acm.pku.edu.cn/
吉林大學(xué)的 Online Judge -http://acm.jlu.edu.cn/
四川大學(xué)的 Online Judge -http://cs.scu.edu.cn/acm
汕頭大學(xué)的 Online Judge -http://acm.stu.edu.cn/
中科大的 Online Judge -http://acm.ustc.edu.cn/index.php
哈工大的 Online Judge -http://acm.hit.edu.cn/acm.php
西班牙的 Universidad de Valladolid -http://acm.uva.es/
俄羅斯烏拉爾大學(xué) -http://acm.timus.ru/
年初八,我回來了.
記得在清遠(yuǎn)的時(shí)候,同學(xué)朋友聽到我初八回去的時(shí)候,都是那一臉的驚訝,然后都很不由自主地問我回去做什么,然后我說項(xiàng)目還沒做完,然后他們都豎起拇指,說我厲害.
我很感謝朋友們的稱贊,可是真的那么厲害嗎?也許我沒什么自信.雖然人家說,大一做項(xiàng)目賺錢已經(jīng)很厲害啦,可是就我知道,我在做的項(xiàng)目,根本沒有什么深度可言,只是一些邏輯上的組合罷了.
記得每次回去的時(shí)候,爸爸都說,要讀好書,先不要想著賺錢.爸爸說得是有道理的,放假后每天在趕項(xiàng)目,每天在重復(fù)相同的事情,覺得真的有點(diǎn)無聊,有點(diǎn)郁悶......但我又想,拿點(diǎn)經(jīng)驗(yàn)吧,總比看了書,不實(shí)踐好......
人有時(shí)候就是很奇怪,經(jīng)常自我矛盾,不過我想這次我是不會(huì)的了,我已經(jīng)決定暫時(shí)不在做項(xiàng)目了,因?yàn)槲疑钪约旱幕A(chǔ)差,記得xmm所過,只要努力,哪個(gè)方向都會(huì)成功的,所以決定了還是先看看書,搞下acm好了,最近發(fā)現(xiàn),老是做項(xiàng)目,人會(huì)變得遲鈍......
終于也體會(huì)到
連續(xù)幾天工作10多小時(shí)的滋味....
不過也值得,沒吃過苦,是應(yīng)該吃點(diǎn)的....
花了一天的時(shí)間,終于完成管理地區(qū)的功能.
本以為這個(gè)功能很簡(jiǎn)單,但做起來,很多的細(xì)節(jié)要注意,這樣堆積起來,就是時(shí)間了.
行業(yè)管理今天是做不完的了,明天再奮斗吧.
Ep:做功能的時(shí)候,是應(yīng)該把功能想清楚再做的.