C++ 从一个数字向上计数到另一个数字
C++ Counting upwards from one number to another
所以我的程序必须要求用户输入两个数字,然后程序必须找出哪个是最低的数字,哪个是最高的数字。然后程序从最低到最高计数并显示它(例如 3、4、5、6(。我认为问题出在 if else 声明中,但我不确定。
using namespace std;
void no_1_count_from_min_to_max(int min, int max);
int main()
{
int min=0;
int max=4;
int first;
int second;
int third;
cout<<"Enter first number:";
cin>>first;
cout<<endl;
cout<<"Enter second number:";
cin>>second;
cout<<endl;
cout<<"Enter third number:";
cin>>third;
cout<<endl;
no_1_count_from_min_to_max(min,max);
if (first>second){
first = max;
second = min;
}
else{
second = max;
first = min;
}
return 0;
}
void no_1_count_from_min_to_max(int min, int max){
for (int i = min; i<=max; i++){
cout<<setw(4)<<i;
}
cout<<endl;
}
你永远不会修改min
或max
。 在main
开始时将它们设置为 0 和 4,并且从不更新它们。
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 运行同一解决方案的另一个项目的项目
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 将向量之间的数字放在另一个向量之间<vector>>如果两个数字的差值为 1
- 根据另一个数字的可整除性返回子数组中的索引
- C++ 从一个数字向上计数到另一个数字
- 为什么数组在一个文件中打印,但在发送到另一个文件时却缺少数字
- 将映射的每个键中的数字数据与另一个数值进行比较
- 更快的方法将数字从范围转换为另一个范围
- 维护多集中数字的排序列表和另一个集合中的累积总和
- 程序检查是否包含另一个数字
- 如何计算一个数字到另一个数字中的数量
- 找到最大.任何给定数字的功率值小于另一个给定数字
- BITWISE-如何检查二进制号是否包含另一个数字
- 在另一个字符串中查找一串数字
- 找到最接近另一个数字 c++ 的数字
- 将一个以10为基数的数字转换为另一个基数
- 查找数组中与另一个给定数字最接近的数字
- 如何创建一个计数函数来从另一个函数中计算序列中的数字数量
- 如果我将数字存储为整数数据类型,如何检查另一个数字中是否存在一个数字