運行結果換行,只用了std::endl; 實際看資料有“/r/n”,實際怎麼用,沒看出效果來。。。笨啊。。
#include <iostream>
int main ()
{
int v1,v2,lower,upper ;
std ::cout <<"enter two numbers:"<<std ::endl ;
std ::cin >>v1 >> v2 ;
if( v1 >v2 )
{ lower =v2 ;upper =v1 ;}
else { lower =v1 ;upper = v2 ;}
int sum=0;
for (int val =lower ;val <=upper ; val ++)
sum += val ;
std ::cout <<"the lower is "<<lower <<std ::endl ;
std ::cout <<"the upper is " <<upper <<std ::endl ;
std ::cout <<"the sum from "<<lower<<" to "<< upper <<" is " << sum << std ::endl ;
system ("pause");
return 0;
}
運行結果