c++编写的输入两个数a,b,让其从a加到b,帮忙看一下哪里有错误?谢谢。
#include"stdafx.h"#include<iostream>intmain(){std::cout<<"请输入两个数:"<<std::endl;inta=0,...
#include "stdafx.h"
#include<iostream>
int main()
{
std::cout << "请输入两个数:" << std::endl;
int a = 0, b = 0, c = 0, d = 0;
std::cin >> a >> b;
while (c >= b) {
d = c + a;
c = a + 1;
}
std::cout << a << "加到" << b << "等于" << d << std::endl;
return 0;
} 展开
#include<iostream>
int main()
{
std::cout << "请输入两个数:" << std::endl;
int a = 0, b = 0, c = 0, d = 0;
std::cin >> a >> b;
while (c >= b) {
d = c + a;
c = a + 1;
}
std::cout << a << "加到" << b << "等于" << d << std::endl;
return 0;
} 展开
1个回答
2018-05-23
展开全部
哪里看呢??试写了一下
#include<iostream>
using namespace std;
int main(){
int a,b,i,sum=0;
cout<<"input a and b"<<endl;
cin>>a>>b;
for(i=a;i <= b; i++){
sum+=i;
}
cout<<sum;
}
追问
能帮我看看我上边写的那个哪里不对行吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询