#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
double real(const char* msg) {
cout << msg;
double value;
cin >> value;
cin.ignore(cin.rdbuf()->in_avail());
return value;
}
int main() {
auto x = real("x: ");
auto y = real("y: ");
x > y? swap(x, y) : void();
auto a = static_cast<long long>(ceil(x));
if (a == x) ++a;
auto b = static_cast<long long>(trunc);
if (b == y) --b;
auto count = b - a + 1;
for (auto x = a; x <= b; ++x) cout << x << ' ';
cout << "\ncount: " << count << '\n';
system("pause > nul");
}
Тут можно вывод сделать поаккуратнее. Например, так:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std; int d(int n)
{ if (n == 0) return 2; int m = 1; if (n < 0)
{ n = abs; ++m; } while { n /= 10; ++m; }
return m; }
int main() { double x, y; cout << "x y » ";
cin >> x >> y; int a = ceil(x), b = floor,
max = d(a), c = d(b), l, m = 0, n; if (c > max)
max = c; l = 52 / max; for (n = a; n <= b; n++)
{ cout << setw(max) << n; ++m; if (m == l)
{ m = 0; cout << endl; } } if (m) cout << endl;
cout << b + 1 - a << " numbers" << endl;
system("pause > nul"); return 0; }
В операторе l = 52 / max под вывод на экран задаются не более чем пятьдесят две позиции.