1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int n; 7 while(scanf("%d",&n) == 1) 8 { 9 int k = 1, s = 0; 10 for(;;) 11 { 12 s += k; 13 if(s >= n) 14 { 15 printf("%d/%d",s-n+1,k-s+n); 16 break; 17 } 18 k++; 19 } 20 21 } 22 return 0; 23 }
简单数学问题 找到规律即可。第一行的分子都是1 ,分母从1 开始递增。控制好便可以了