编写一程序,求1+2+3+……的前N项和,直到其和刚刚1000止,将N值保存在DX中,累加和保存在AX中
来源:百度知道 编辑:UC知道 时间:2024/05/24 17:22:11
用两种方法实现
1
for n = 1 to 500
if ax > 1000 then
exit for
else
ax = ax + n
end if
next
dx = n
2
do while dx > 1000
dx = dx + 1
ax = ax + dx
loop
楼主,这个问题根本就无解呀.你看哈DX=44时,AX=990;当DX=45时,AX=1035.
不过如果把等于一千换成不大于一千且最接近一千,则有如下程序:
#include <stdio.h>
main()
{int DX=1,AX=0;
while (AX<=1000)
{AX=AX+DX;
DX++;}
AX=AX+1-DX;
DX=DX-2;
printf("DX=%d AX=%d",DX,AX);
getchar();
}
编写一个Application程序,求1!+2!+3!+ … +20!
编写一C程序,求数列1,-3!,5!,-7!,…,(-1)n-1(2n-1)!前n项的和。
编写一程序,求数列1,-3!,5!,-7!,…,(-1)n-1(2n-1)!前n项的和。
编写程序,求1+2+3……+1000的值并输出。
编写程序:求1+2+3……+99+100的和
编写一个C程序,求1!+2!+3!+4!…10!的和
用VB编写程序,求1+2+3+…+100的和
用VB编写程序,求1!+2!+3!.............+10!
编写一个c程序 求1!+2!+3!+4!+...+20!
试编写程序,求1+2!+3!+...+20!的值