日历

2008 9.6 Sat
 123456
78910111213
14151617181920
21222324252627
282930    
«» 2008 - 9 «»

文章搜索

日志文章

2008年05月26日 13:13:40

为机器思考

Problem Description
Your task is to 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, and followed by a blank line.
Sample Input
1 5
10 20
Sample Output
6

30

Author
lcy
Recommend
JGShining
===========================================================
Run ID   Submit Time   Judge Status   Pro.ID   Exe.Time   Exe.Memory
648012 2008-05-26 10:07:47   Accepted   1095   0MS 0K   198 B  
648009 2008-05-26 10:01:42   Accepted   1095   15MS 0K   213 B
===========================================================
648009:
#include<iostream>
using namespace std;
void main()
{
int a=0,b=0,c[100]={0},i=0,j=0;
while(cin>>a>>b)
{
    c=a+b;
    i++;
    a=0;
    b=0;
}
while(j<i)
{
    cout<<c[j]<<endl<<endl;
    j++;
}
}
==========================================================
648012:
#include<iostream>
using namespace std;
void main()
{
int a[100]={0},b[100]={0},i=0,j=0;
while(cin>>a>>b)
{
    i++;
}
while(j<i)
{
    cout<<a[j]+b[j]<<endl<<endl;
    j++;
}
}
==========================================================
上午做的一道简单的输出格式题,在不同的位置进行求和所得的结果一致,但是代码量有所不同,运行时间也有所不同。

作为coder,一定要想办法在代码上简化机器的负担,尤其是在单片机等小型环境上面进行编程工作的时候,一定要努力降低存储器的占用,优化代码,增快其运行速度。。。

下午还有课,抓紧时间AC。。。

Tags: ACM  

类别: c/c++ |  评论(1) |  浏览(415) |  收藏
1楼 [匿名]ymwa9noe 2008年08月15日 13:04:13 Says:
%5Burl=http://www.lxwltg.com/%5D%E5%88%9B%E9%B8%BF%E8%BD%AF%E4%BB%B6%EF%BC%8C%E7%8E%B0%E5%9C%A8%E5%8F%AF%E4%BB%A5%E5%90%914200%E5%AE%B6%E5%9B%BD%E5%86%85%E5%88%86%E7%B1%BB%E4%BF%A1%E6%81%AF%E6%B8%AF%E5%8F%91%E5%B8%83%E4%BE%9B%E6%B1%82%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