分别用while ,do-while,for语句求出前20项和,该怎么写?
分别用while ,do-while,for语句求出前20项和,该怎么写?
日期:2019-10-10 01:25:15 人气:2
#include void main() {int i = 2;int j = 1;int k = 0;int t;double sum = 0;// 注释:1.whilewhile(k < 20){sum += (double)i/j;if (k < 19)printf("%d/%d + ", i, j);elseprintf("%d/%d = %f", i, j, sum);++k;t = j;j = i;i