2007/04/25 | 整理出用WHILE改写的
类别(计算机与编程) | 评论(0) | 阅读(8) | 发表于 10:31

//2002.8.28 while 50+...100,cycle sum it

#include <iostream.h>

main()

{
cout<<"this programme will add A,B,C,D to cycle add."<<endl;
cout<<"now please input the A.value: "<<endl;
long int A,B,C,D;
cin>>A;
cout<<"now please input the B.value: "<<endl;
cin>>B;
cout<<"now please input the C.value: "<<endl;
cin>>C;
cout<<"now please input the D.value: "<<endl;
cin>>D;

long int i=A,X=0;
while (i<=B)
{
X=X+i;
++i;
}

long int j=C,Y=0;
while (j<=D)
{
Y=Y+j;
++j;
}

//long int X=0;
//for (long int i=A;i<=B;++i)
//X=X+i;

//long int Y=0;
//for (long int j=C;j<=D;++j)
//Y=Y+j;

cout<<"the cycle of A and B is: "<<X<<endl;
cout<<"the cycle of C and D is: "<<Y<<endl;

cout<<"the sum of X and Y is: "<<X+Y<<endl;
cout<<"the i is: "<<i<<endl;
cout<<"the j is: "<<j<<endl;

cout<<"have you seen the all result?"<<endl;
char BB;
cin>>BB;
cout<<"byebye!"<<endl;


}

0

评论Comments

日志分类
首页[666]
计算机与编程[133]
EMU[40]
UFOs[24]
房产[127]
音乐[13]
LOG[0]
经济[120]
影视[3]
物理[7]
数学[8]
社会[105]
职场[9]
生物医学[18]
生活[59]