📄 1.cpp
字号:
/**********chapter5 T1计算并输出两个整数间(包括这两个整数)所有整数之和*********/
#include<iostream>
int main()
{
using namespace std;
int a,b;
cout<<"Please input two integer.\n";
cin>>a>>b;
int sum=0;
int temp;
if (a>b) //确定输入的两个整数的大小
{
temp=a;
a=b;
b=temp;
}
if(a!=b) //求和
{
for(int i=a;i<=b;i++)
{
sum+=i;
}
}
else
sum=2*a;
cout<<"The sum of the integers between the the two integers is:"<<sum<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -