https://www.youtube.com/watch?v=TdKZNtmtBiY&list=PLggQDlmnRsqDVUJIYqe2YnfaBoVPa-3Nx&index=7
數學題目在上,c語言程式碼在下。
其中第200項的數字,
我的c算出來是10/11,但老師解出來是11/10,
請問我的程式碼哪裡寫錯???
謝謝大大指導m(__)m
註:我分子分母上下顛倒了,已解答,謝謝各位。(沒得刪帖)
int i=0, j=0, k=0, sn=0, m=0;
for (k=1; k<30; k++) { // k is group, i guess the result under group20
printf("\n above total = %2d; group %2d : ", m, k);
for (i=1, j=k; i<30, j>0; i++, j--) {
// i is numerator, j is denominator
m+=1; // counter item
printf("%d/%d, ", i, j);
if ((i==7)&&(j==8)) {
sn = ((1+k)*k/2)-6; // after 7/8, have 6 item, need total-6
printf("%d/%d in line %d, and no %d\n", i, j, k, sn);
}
if (m==200) {
printf("\nno 200 is %d / %d", i, j);
// (10/11) ???? teacher's answer is (11/10)
return 0;
}
}
}