1 #include<iostream> 2 #include<iomanip> 3 using namespace std; 4 int main(){ 5 int m,n,c=0,sum=0; 6 cin>>m>>n; 7 while(m<=n){ 8 if(c&&c%5==0) 9 cout<<endl; 10 cout<<setiosflags(ios::right)<<setw(5)<<m; 11 sum+=m; 12 m++; 13 c++; 14 } 15 cout<<endl; 16 cout<<"Sum = "<<sum<<endl; 17 return 0; 18 }
循环-01. 求整数段和(15),布布扣,bubuko.com
原文地址:http://www.cnblogs.com/gnodidux/p/3820234.html