只是粘在此代码中,我必须创建一个数学表
Just stuck in this code, I have to create a math table
我有这个代码,这给了我错误,我不知道如何修复它。我不知道我做错了哪一部分。
我已经制作了这样的代码,但是没有给用户一个选择,例如:
int counter;
for (counter=1; counter<=100000; counter=counter+1)
{
cout<<"2x"<<counter<<"="<<2*counter<<"n";
此代码为我提供了2个。
#include <iostream>
#include <cstdlib>
using namespace std;
main()
{ int counter, number, maxMultiplier;
{
cout>> "Please enter the number for which you want a table: ";
cin<< number;
cout>> "Please select the multiplier up to which you want a table: ";
cin>> maxMultiplier;
}
for (counter=1; counter<=maxMultiplier; counter=counter+1)
{ cout<<number<<"x"<<counter<<"="<<number*counter<<"/n";
}
{system("pause");}
return main();
}
用户应该能够输入所需的表格的数字以及想要的表格。一直像2x1 = 2 ......... 2x10 = 20
清洁代码并考虑到Typeia和我的言论:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int number, maxMultiplier;
cout << "Please enter the number for which you want a table: ";
cin >> number;
cout << "Please select the multiplier up to which you want a table: ";
cin >> maxMultiplier;
for (int counter = 1; counter<=maxMultiplier; ++counter)
{
cout<<number<<"x"<<counter<<"="<<number*counter<<"n";
}
system("pause"); // I don't like, pause does not exist under Linux etc
return 0;
}
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 试图在visual studio上用C++创建一个桌面应用程序
- 如何创建一个空的全局类并在启动时实例化它
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何创建一个QTableWidgetItem,用长文本右对齐,左边有省略号
- 我正在尝试使用 c++ 创建一个货币转换程序,我不知道如何继续
- visual是否可以在c++中创建一个接收无限数量相同类型(或至少相当数量)参数的函数
- 试图创建一个多线程程序来查找0-100000000之间的总素数
- 如何创建一个函数来计算并返回平均值、最大值和最小值
- 如何使用CLion在Mac上创建一个新的.txt文件
- 如何在没有数据拷贝的情况下从指针创建一个Eigen VectorXd对象
- 在c++中为double类型的数组创建一个unique_ptr
- 我可以创建一个包含两个变量的 for 循环,但时间复杂度仍然为 O(n) 吗?
- GLEW/GLUT:调用init并创建一个窗口后,取消初始化并重新初始化?
- 我想通过带有C++和Python的插件创建一个可扩展的应用程序
- 在 c++ 中,有一种方法可以创建一个包含地图作为值的树状地图?
- 模板化接口 - 创建一个泛型模板类以返回任何容器
- 创建一个包含 c++ 默认值的环境文件
- 如何创建一个类,以便向量工作 std::vector<MyClass<int>> v{ 1,2,3 };