# 計算直角三角形的邊長 ``` #include <stdio.h> #include <math.h> int gcd(int m, int n) { if (n == 0) return m; return gcd(n, m % n); } int main(){ float a; int b, c; for (int j=5; j<=500; j++) { b=j*j; for (int i=1; i<=j*sqrt(2)/2; i++) { c = a = sqrt(b-i*i); if (a==c && gcd(c,i)==1) printf("%d %d %d\n", i, c, j); } } } 3 4 5 5 12 13 8 15 17 7 24 25 20 21 29 12 35 37 9 40 41 28 45 53 11 60 61 16 63 65 33 56 65 48 55 73 13 84 85 36 77 85 39 80 89 65 72 97 20 99 101 60 91 109 15 112 113 44 117 125 88 105 137 17 144 145 24 143 145 51 140 149 85 132 157 119 120 169 52 165 173 19 180 181 57 176 185 104 153 185 95 168 193 28 195 197 84 187 205 133 156 205 21 220 221 140 171 221 60 221 229 105 208 233 120 209 241 32 255 257 23 264 265 96 247 265 69 260 269 115 252 277 160 231 281 161 240 289 68 285 293 136 273 305 207 224 305 25 312 313 75 308 317 36 323 325 204 253 325 175 288 337 180 299 349 225 272 353 27 364 365 76 357 365 252 275 373 135 352 377 152 345 377 189 340 389 228 325 397 40 399 401 120 391 409 29 420 421 87 416 425 297 304 425 145 408 433 84 437 445 203 396 445 280 351 449 168 425 457 261 380 461 31 480 481 319 360 481 44 483 485 93 476 485 132 475 493 155 468 493 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up