Run ID:153886
提交时间:2026-05-24 10:55:37
#include <iostream> using namespace std; int main() { // 定义变量 int n; // 提示用户输入 cout << "请输入一个整数 n (0 < n < 100):"; cin >> n; // 判断输入是否合法 if (n > 0 && n < 100) { cout << "1 到 " << n << " 的数字是:" << endl; // 循环输出 1 到 n for (int i = 1; i <= n; i++) { cout << i << " "; } cout << endl; // 换行 } else { // 输入不合法提示 cout << "输入错误!请输入 0 到 100 之间的整数。" << endl; } return 0; }