fork download
  1. #include <stdio.h>
  2. int main(void)
  3. {
  4. int a, b, c; /* 前提1:a<bとする */
  5. printf("cの値は? ");
  6. scanf("%d", &c);
  7. for (a = 1; a * a < c * c / 2; ++a) { /* from 前提1 */
  8. for (b = a + 1; a * a + b * b < c * c; ++b);/* from 前提1 */
  9. if (a * a + b * b == c * c) {
  10. printf("aは%dで、bは%d\n", a, b);
  11. return 0;
  12. }
  13. }
  14. printf("存在しません\n");
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 2296KB
stdin
5
stdout
cの値は? aは3で、bは4