只是粘在此代码中,我必须创建一个数学表

Just stuck in this code, I have to create a math table

本文关键字:创建 一个 代码      更新时间:2023-10-16

我有这个代码,这给了我错误,我不知道如何修复它。我不知道我做错了哪一部分。

我已经制作了这样的代码,但是没有给用户一个选择,例如:

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;
}
相关文章: