本地编译器黑框输入输出
我在网上做题,在本地测试的时候需要黑框输入输出,但数据通常是按行给出,比如说两行两个输出,但我把数据粘贴在黑框里点击回车,只会出现一个输出,第二个输出害得要再手动输入一组数据,有没有什么办法可以同时输出所有的结果呢?
比如说我下面的代码,输入
0 0 0 1
0 1 1 0
只会输出第一个结果也就是1.00
#include <cstdio>
#include <cmath>
int main(void){
double x1,x2,y1,y2;
while((scanf("%lf %lf %lf %lf\n",&x1,&y1,&x2,&y2)) != EOF){
if(x1 == x2){
if(y1 >= y2)printf("%.2f",y1 - y2);
else printf("%.2f",y2 - y1);
}
else if(y1 == y2){
if(x1 >= x2)printf("%.2f",x1 - x2);
else printf("%.2f",x2 - x1);
}
else{
printf("%.2f",sqrt(pow(x1 - x2,2.0) + pow(y1 - y2,2.0)));
}
}
return 0;
}