Código
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { string profe[5]; string materia[5][3]; int salon[5][3]; int rep; int i=0,j=0,k=0,l=0; srand(time(NULL)); do{j=0; cout<<"Ingrese profesor No "<<i+1<<": "; cin>>profe[i]; while(j!=3){ cout<<"Ingrese materia #"<<j+1<<" del profesor "<<profe[i]<<": "; cin>>materia[i][j]; do{rep=true; salon[i][j]=rand()%15+301; if((i>0)||(j>0)){k=0;l=0; while((k=!i)&&(l!=j)){ if(salon[i][j]==salon[k][l]){ rep=false;} if(l==2){l=0;k++;}else{ l++;}}} }while(rep!=true); j++;}i++; }while(i!=5); i=0; cout<<"\n\nMaestro\tMateria\tSalon\n"; while(i!=5){j=0; cout<<endl<<profe[i]; while(j!=3){ cout<<"\n\t"<<materia[i][j]<<"\t"<<salon[i][j]; j++;}i++;} return 0; }
Modificado: es mas fácil leer el código utilizando el coloreado.