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

Re:我的程序调试第一组数据多了一,第二组是对的,为什么呢?谢谢

Posted by xiaoha at 2005-01-05 15:36:02 on Problem 1922
In Reply To:我的程序调试第一组数据多了一,第二组是对的,为什么呢?谢谢 Posted by:Ashley at 2005-01-02 21:01:05
#include<stdio.h>
#include<math.h>
void main(){
	while(1){
		int n,i;
    	scanf("%d\n",&n);
		int a[10010][2];//数组好像是开小了a[10001][2];
		if(n==0) break;
		float num,t;
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i][0],&a[i][1]);//好像这要有换行副
		}
		for(i=0;i<n;i++){
			if(a[i][1]>=0){
			    num=(float)(4500.0*18/a[i][0]/5+a[i][1]);//整形处以整形得到的还是整形
				break;}
		}//你可以接着上一个运行,i可以借着循环
		for(i=0;i<n;i++){
            if(a[i][1]>=0){
			    t=(float)(4500.0*18/a[i][0]/5+a[i][1]);
				if(t<num) num=t;}
		}
		printf("%d\n",(int)ceil(num));//如果num是12那它加上1当然是错误的了,这应用一个向上取整的函数#include<math.h> (int)ceil(num);
	}
}

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