1.10 编写程序,提示用户输入两个整数,打印出这两个整数所指定的范围内的所有整数
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main() {
int v1 = 0, v2 = 0;
cout << "Please enter two numbers: " << endl;
cin >> v1 >> v2;
while (v1 < v2) {
cout << v1 << " ";
++v1;
}
while (v1 > v2) {
cout << v1 << " ";
--v1;
}
cout << v2;
return 0;
}
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main() {
int v1 = 0, v2 = 0;
cout << "Please enter two numbers: " << endl;
cin >> v1 >> v2;
for (; v1 < v2; ++v1)
cout << v1 << " ";
for (; v1 > v2; --v1)
cout << v1 << " ";
cout << v2;
return 0;
}