avatar
law 没人气啊# Law - 律师事务所
l*8
1
We have currently an opening of Internship in Boston area on renewable
energy fields, such as Hydrogen, Wind Turbine and solar panel. We look a
student who can speak Mandarin Chinese.
We are looking for an individual who is:
• Major in Engineering fields
• Speak Mandarin Chinese
Please send resume to: P********[email protected]
We consider local candidate(MA) only
avatar
Q*Q
2
咔嚓,拦腰截屏
avatar
r*e
3
#include
using namespace std;
int main()
{
//part 1 below
int sum=0,v1;
while(cin>>v1)
{
sum+=v1;
}
cout<< "sum is "<< sum<//part 2 below
cout<< "imput v2 "<int v2=0;
cin>>v2;
cout<return 0;
}
第一部分读入多个数,然可求和.用字母或 ctrl+z 做结束符时,第二部分没有执行读
入v2,直接输出v2结束,返回零.为啥啊?
avatar
m*t
4
business那边热闹多了. 是因为law school stress大太多了吧~~
avatar
b*r
5
错在while()那句.
avatar
I*o
6
念的人少吧

【在 m******t 的大作中提到】
: business那边热闹多了. 是因为law school stress大太多了吧~~
avatar
r*e
7
how a

【在 b********r 的大作中提到】
: 错在while()那句.
avatar
b*r
8
我猜你用字母或者ctrl-z终断while的时候,不是正常返回0的终断.
不过你还是等大牛们回答吧.

【在 r**e 的大作中提到】
: how a
avatar
j*a
9
#include
using namespace std;
int main()
{
//part 1 below
int sum=0,v1;
while(cin>>v1)
{
sum+=v1;
cin.get(); //get the space or the return character
}
cin.clear(); // clear out the non-numeric character
cin.get(); // get the return character
cout<< "sum is "<< sum<//part 2 below
cout<< "imput v2 "<int v2=0;
cin>>v2;
cout<return 0;
}
avatar
r*e
10
重新启动流,got it. thanks.

【在 j*****a 的大作中提到】
: #include
: using namespace std;
: int main()
: {
: //part 1 below
: int sum=0,v1;
: while(cin>>v1)
: {
: sum+=v1;
: cin.get(); //get the space or the return character

avatar
H*a
11
The error happened at
while(cin>>v1)
Check this out: http://www.cplusplus.com/reference/iostream/istream/operator>>/
"Errors are signaled by modifying the internal state flags:
[flag]
failbit
[error]
The input obtained could not be interpreted as an element of the appropriate
type."
cin is an object of class istream, once error occurs, "an exception of type
ios_base::failure is thrown", cin therefore won't work anymore. That's why
v2 is still 0.

【在 r**e 的大作中提到】
: #include
: using namespace std;
: int main()
: {
: //part 1 below
: int sum=0,v1;
: while(cin>>v1)
: {
: sum+=v1;
: }

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。