【发布时间】:2021-01-24 13:04:07
【问题描述】:
我想创建一个算法,当用户被要求从键盘输入 n 时,您可以将前 n 个数字(从 1 到 n)相加。
#include <stdio.h>
int main() {
int x,k,j;
scanf("%d",&x);
int y= 1;
do {
int k= y;
int y= y+1;
int j= k+y;
} while(y<x);
printf("The Total sum of the number is: %d ", j);
}
我写了这个,但它给了我这个错误:
[Error] ld returned 1 exit status
【问题讨论】:
标签: c loops runtime-error