| ||||||||||
| 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 | |||||||||
Re:我的程序调试第一组数据多了一,第二组是对的,为什么呢?谢谢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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator