First commit
This commit is contained in:
34
IUT/Info1/TD/Exercices/9.5_table_mult/fonctions.cpp
Normal file
34
IUT/Info1/TD/Exercices/9.5_table_mult/fonctions.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <math.h>
|
||||
|
||||
#include "fonctions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
unsigned int nombre_de_Chiffres(unsigned int a) {
|
||||
return log10(a) + 2;
|
||||
}
|
||||
|
||||
void table_De_multiplication(unsigned int n) {
|
||||
unsigned int espacement;
|
||||
|
||||
espacement = nombre_de_Chiffres(n*n);
|
||||
cout << setw(espacement) << "";
|
||||
|
||||
for (unsigned int i = 1; i <= n; i++) {
|
||||
cout << setw(espacement) << i;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
||||
for (unsigned int y = 1; y <= n; y++) {
|
||||
cout << setw(espacement) << y;
|
||||
for (unsigned int x = 1; x <= n; x++) {
|
||||
cout << setw(espacement) << x*y;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user