С помощью оператора цикла for, разработать программу, которая будет выводить таблицу умножения введенного пользователем числа с клавиатуры.
Итак, у вас уже есть подсказка, нужно воспользоваться оператором цикла for. Чтобы красиво вывести на экран таблицу умножения, прочитайте статью о форматировании потока вывода в С++, она вам очень поможет. Результат, который у вас должен получиться:
#include <iostream>
using namespace std;
int main()
{
setlocale (LC_ALL, "RUS");
int chislo;
cout<<"\t\t\tТаблица умножения введенного числа\n";
cout<<"\t\t\t----------------------------------\n";
cout<<endl;
cout<<"Введите число: ";
cin>>chislo;
cout<<endl;
for (int j=1; j<=10; j++)
{
cout<<j<<" * "<<chislo<<" = "<<j*chislo<<endl;
}
cout<<endl;
return 0;
}
Результат работы программы:
CppStudio.com
Таблица умножения введенного числа ---------------------------------- Введите число: 5 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25 6 * 5 = 30 7 * 5 = 35 8 * 5 = 40 9 * 5 = 45 10 * 5 = 50
Комментарии
colt
#include "stdafx.h" #include "iostream" #include "windows.h" using namespace std; int intNumber; int _tmain(int argc, _TCHAR* argv[]) { SetConsoleCP(1251); SetConsoleOutputCP(1251); while(true) { system("CLS"); cout<<"\t\tТаблица умножения введённого числа\n"; cout<<"\t\t----------------------------------\n\n"; cout<<"Введите число: "; cin>>intNumber; cout<<"\n"; for (int i=1;i<=10;i++) cout<<i<<" * "<<intNumber<<" = "<<intNumber*i<<"\n"; system("PAUSE"); } return 0; }gro
#include <iostream> using namespace std; int main() { setlocale(LC_ALL,"rus"); int unsigned number=10; while (number>9) { cin.clear(); _flushall(); cout << "Введите число: "; cin >> number; } for (int i=1; i<=10; i++) { cout.width(3); cout << i << " * " << number << " = " << i*number << endl; } }Migizi
#include <conio.h>
#include <iostream>
using namespace std;
int main(void)
{
setlocale(LC_ALL, «Russian»);
int y;
cin >> y;
for (int i = 1; i <= 10; i++)
cout << i << » * » << y<<» = «<<i*y << endl;
_getch();
return 0;
}
Anufree
#include <iostream> #include <conio.h> using namespace std; int main() { setlocale(LC_ALL, "Russian"); int a; cout << "\t\t***Таблица умножения введенного числа***\n" << "\t\t----------------------------------------\n"<< endl; cout << "Введите число: "; cin >> a; cout << endl; for(int i = 1; i <= 10; i++) cout << i << " * " << a << " = " << i * a << endl; _getch(); return 0; }