TP7: formattage
This commit is contained in:
@@ -16,7 +16,14 @@ void Entreprise::saisie(ifstream& s) {
|
||||
}
|
||||
|
||||
void Entreprise::affichage() {
|
||||
cout << m_company << " " << m_country << " " << m_market_value << " " << m_sector << " " << m_turnover << " " << m_employees << " " << m_rank_2015 << " " << m_rank_2014;
|
||||
format(m_company, 20);
|
||||
format(m_country, 15);
|
||||
format(m_market_value, 10);
|
||||
format(m_sector, 10);
|
||||
format(m_turnover, 10);
|
||||
format(m_employees, 6);
|
||||
format(m_rank_2015, 3);
|
||||
format(m_rank_2014, 3);
|
||||
}
|
||||
|
||||
int Entreprise::rank_progress() const {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "Pays.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "getio.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -14,5 +16,10 @@ void Pays::saisie(ifstream &in) {
|
||||
}
|
||||
|
||||
void Pays::affichage() {
|
||||
cout << Region << " " << Nom << " " << Population;
|
||||
// format(Region, 10);
|
||||
format(Nom, 20);
|
||||
cout << setprecision(10);
|
||||
format(Population, 10);
|
||||
format(Area, 10);
|
||||
// << setprecision(10) << Population << " " << Area;
|
||||
}
|
||||
12
TP7/getio.h
12
TP7/getio.h
@@ -1,9 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void getfloat(ifstream& s, float& f, const char sep);
|
||||
void getint(ifstream& s, int& f, const char sep);
|
||||
|
||||
template <class T>
|
||||
void format(T t, int w) {
|
||||
cout << left << setw(w) << t << " ";
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void format(T t) {
|
||||
format(t, 4);
|
||||
}
|
||||
Reference in New Issue
Block a user