[心得] runtime 0.20
因為輸入資料為 浮點數 所以用 double 宣告陣列, 以%lf方式儲存
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 10
int main()
{
double array[MAXSIZE ][MAXSIZE ];
double a, b;
char s[MAXSIZE];
int m=0;
int i,j;
int counter =1;
int flag=0;
while(scanf("%s",&s[m])==1){
if(s[m]=='*')
break;
scanf("%lf %lf %lf %lf",&array[m][0],&array[m][1],&array[m][2],&array[m][3]);
m++;
}
while(scanf("%lf %lf",&a,&b)==2){
if(a==9999.9 ||b==9999.9)
break;
for(i=0;i<=m;i++){
if(a >array[i][0]&&a<array[i][2]&& b >array[i][3]&&b <array[i][1]){
flag =1;
printf("Point %d is contained in figure %d\n",counter,(i+1));
}
}
if(flag == 0)
printf("Point %d is not contained in any figure\n",counter);
counter++;
flag = 0;
}
system("pause");
//return 0;
}
沒有留言:
張貼留言