| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
about problems 1000第一次写的:
#include <iostream>
using namespace std;
int main()
{
int a,b;
cout << "This program accepts two inputs a,b.(a>=0 and b<=10)\n";
//题目是要求A>=0,B<=10吗?
cin >> a >>b;
if (a>0||a==0)
{
if(b<10||b==10)
{
cout << a+b;
}
else
{
cout << "Input b is out of range,please choose a number";
cout << "smaller than 10 or equal with 10 as the second input";
}
}
else
cout << "Inputs out of range!";
}
第一次做ACM,想问下,不能加我的这些错误处理语句是吗?加了就是错的?
但是真正编程时,对错误的处理是很重要的啊,ACM里的都不考虑超出范围怎么办吗?
只用考虑在范围内输出结果吗? 这样对全面性考虑的训练不太好吧~
第二次交的这个就通过了:
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >>b;
if (a>=0&&b<=10)
cout << a+b;
}
然后第三次交底下的HINT(HINT就是正确答案么?):
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >>b;
cout << a+b;
}
居然耗时0MS也通过了,我都无语了,题目上不是这样
Two integer a,b (0<=a,b<=10)写的么,有谁能告诉我怎么回事么?
(THANK YOU!)
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator