| ||||||||||
| 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 | |||||||||
请教:两个代码一样为什么运行结果就不同呢??#include<iostream.h>
main()
{
float c,n,p;
cin>>c;
while(c!=0)
{ for(n=1,p=0;p<c;n++)
p=p+(1/(n+1));
cout<<(n-1)<<" "<<"card(s)\n";cin>>c;}
}
#include<stdio.h>
main()
{
float n,c,p;
scanf("%f",&c);
while(c!=0)
{
for(n=1,p=0;p<c;n++)
{ p=p+(1/(n+1));
}
printf("%d card(s)\n",(n-1));
scanf("%f",&c);
}
}
一个是C,一个是C++,代码一样,结果怎么就不一样呢
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator