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

初一中学生搞出来的简单精度题,2次性AC有点惭愧啊,贴代码

Posted by xiaosa001 at 2011-07-26 12:22:29 on Problem 1003
#include <stdio.h>
#include <stdlib.h>
float a,b=0.0,c,d;
int e;
int aa[100001];
int f;
int main () {
    f=2;
    int g=0;
    while(1){
             scanf("%f",&a);
             if(a==0.0)break;
             while(b<=a){b+=1.0/f;
             g++;
             f++;
             if(b>=a){aa[e]=g;
             e++;
             b=0.0;
             g=0;
             f=2;
             break;
             }
             }
             }
    for(int h=0;h<e;h++){
            printf("%d card(s)\n",aa[h]);
            }
             system("pause");
}
    

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