Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define d 3
- using namespace std;
- struct struttura
- {
- int matrice[d][d];
- int posizione[2] ;
- } ;
- int main()
- {
- struttura matrices[9] ;
- ifstream file ;
- file.open("input.txt") ;
- if (!file)
- {
- cout << "ERRORE: File non presente o danneggiato" ;
- system("pause") ;
- }
- int a = 1 ;
- for (int i = 0 ; i < d ; i++ )
- {
- for (int j = 0 ; j < d ; j++ )
- {
- file >> matrices[0].matrice[i][j] ;
- matrices[a].posizione[0] = {i} ;
- matrices[a].posizione[1] = {j} ;
- a++ ;
- }
- }
- // stampa matrice
- a = 1 ;
- cout << "Stampa matrice: " << endl ;
- for (int i = 0 ; i < d ; i++ )
- {
- for (int j = 0 ; j < d ; j++ )
- {
- cout << "|" << matrices[0].matrice[i][j] << "| " ;
- cout << matrices[a].posizione[0] << matrices[a].posizione[1] << " " ;
- a++ ;
- }
- cout <<endl ;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement