mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-20 02:59:55 +00:00
65 lines
776 B
C++
65 lines
776 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
void printTableFor();
|
|
void printTableWhile();
|
|
void printTableDoWhile();
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
printTableFor();
|
|
cout << endl;
|
|
printTableWhile();
|
|
cout << endl;
|
|
printTableDoWhile();
|
|
return 0;
|
|
}
|
|
|
|
void printTableFor()
|
|
{
|
|
int max = 10;
|
|
for(int i = 1; i <= max; i++)
|
|
{
|
|
for(int j = 1; j <= max; j++)
|
|
{
|
|
cout << (i*j) << "\t";
|
|
}
|
|
cout << endl;
|
|
}
|
|
}
|
|
|
|
void printTableWhile()
|
|
{
|
|
int max = 10;
|
|
int i = 1, j = 1;
|
|
while(i <= 10)
|
|
{
|
|
while(j <= 10)
|
|
{
|
|
cout << (i*j) << "\t";
|
|
j++;
|
|
}
|
|
j = 1;
|
|
cout << endl;
|
|
i++;
|
|
};
|
|
}
|
|
|
|
void printTableDoWhile()
|
|
{
|
|
int max = 10;
|
|
int i = 1, j = 1;
|
|
do
|
|
{
|
|
do
|
|
{
|
|
cout << (i*j) << "\t";
|
|
j++;
|
|
}while(j <= 10);
|
|
j = 1;
|
|
cout << endl;
|
|
i++;
|
|
} while(i <= 10);
|
|
}
|