编程计算T=1+(1+2)+(1+2+3)+(1+2+3+4)+……+(1+2+3+4+…+20)

日期:2012-07-06 02:52:20 人气:1

编程计算T=1+(1+2)+(1+2+3)+(1+2+3+4)+……+(1+2+3+4+…+20)

不知道你想要什么软件的程序,给你写一个MATLAB的和一个C++的吧。 MATLAB程序: s=0; for i=1:20 for j=1:i s=s+j; end end disp(s); C++程序(我用的是VS2010): #include "iostream" using namespace std; int main() { int s=0,i,j; for(i=1;i<=20;++i) fo
    A+
热门评论