杭电 step1.2.5 Higher Math 的输出格式错误

蚊子前端博客
发布于 2011-07-20 06:00
杭电hdu练习

我知道杭电OJ的输出控制的比较严格,比如最后一个空格、最后一个换行都是应该注意的。

可是这个题就比较郁闷,我特别的注意了最后一个样例的空行是不能输出的,可是这样却PE了。

题目链接:Higher Math

我就纳闷了,怎么回事,怎么是输出格式错误?然后我就去网上搜了一下,还真有这个题,原来好多人都被这个题害的好惨。

最后一个样例的空行竟然是要输出的,不然就是输出格式错误。

看来我想考虑的周全些,却PE了两次。

刚过的代码:

COPYC

#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> int triangle(int x, int y, int z) { if((x*x==y*y+z*z)||(y*y==x*x+z*z)||(z*z==x*x+y*y)) { return 1; } return 0; } int main() { int i, t, x, y, z; scanf("%d", &t); for(i=1; i<=t; i++) { scanf("%d %d %d", &x, &y, &z); printf("Scenario #%d:\n", i); if(triangle(x, y, z)) printf("yes"); else printf("no"); printf("\n\n"); } return 0; }
标签:
阅读(608)

公众号:

qrcode

微信公众号:前端小茶馆

公众号:

qrcode

微信公众号:前端小茶馆