Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请教:两个代码一样为什么运行结果就不同呢??

Posted by snowfall at 2008-03-22 18:03:35 on Problem 1003
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator