#include <iostream> #include <fstream> using namespace std; #define NB_BLOC_HORIZON 32 #define NB_BLOC_VERTI 24 int main() { // [1] Petite intro cout << "Lecture du niveau." << endl; // [2] Ouverture du flux string const nomFichier("level 1.txt"); ifstream fluxIn(nomFichier.c_str()); if (fluxIn) cout << "Ouverture du fichier "<<nomFichier<<" réussie."<<endl; else cout << "Echec de l'ouverture du fichier "<<nomFichier<<"."<<endl; // [3] Création du niveau string nomNiveau; int numeroNiveau; int tableauNiveau[NB_BLOC_VERTI][NB_BLOC_HORIZON]; // [4] Remplissage du niveau getline(fluxIn,nomNiveau); fluxIn >> numeroNiveau; for (int y(0); y<NB_BLOC_VERTI; y++) { for (int x(0); x<NB_BLOC_HORIZON; x++) { fluxIn >> tableauNiveau[y][x]; } } // [5] Affichage du statut cout << "Le niveau n°"<<numeroNiveau<<" s'appelle "<<nomNiveau<<"."<<endl; for (int y(0); y<NB_BLOC_VERTI; y++) { for (int x(0); x<NB_BLOC_HORIZON; x++) { cout << " #O345678X"[tableauNiveau[y][x]]; } cout << endl; } return 0; }