练习1.9
#include<iostream>
int main()
{
int sum = 0, val = 50;
while (val <= 100)
{
sum += val;
++val;
}
std::cout << "Sum of 1 to 10 inclusive is "
<< sum << std::endl;
return 0;
}
练习1.10
#include<iostream>
int main()
{
int val = 10;
while (val >= 0)
{
std::cout << val << ' ';
--val;
}
std::cout << std::endl;
return 0;
}
练习1.11
#include<iostream>
int main()
{
int val1, val2;
std::cout << "Please input two integer:";
std::cin >> val1 >> val2;
while (val1 <= val2)
{
std::cout << val1 << ' ';
++val1;
}
std::cout << std::endl;
return 0;
}