Cpp_Primer_Answers
Cpp_Primer_Answers copied to clipboard
练习1.11的答案有争议
练习1.11此时的学习阶段并未引入for和if,应该使用已学的内容来实现。 下面是我的答案:
#include <iostream>
int main()
{
std::cout << "Enter two numbers: " << std::endl;
int v1, v2;
std::cin >> v1 >> v2;
std::cout << "The integers between " << v1 << " and " << v2 << " are: " << std::endl;
while (v1 <= v2)
{
std::cout << v1 << std::endl;
while (v1 == v2)
{
return 0;
}
++v1;
}
while (v1 >= v2)
{
std::cout << v2 << std::endl;
++v2;
}
return 0;
}