Salut! Am avut de facut la informatica un proiect pentru atestat (sunt a 12-a). Cand vine vorba de problema in sine imi da cateva erori la rularea programului si nu stiu ucm sa o scot la capat. Este cineva dispus sa ma ajute, daca va trimit codul sursa si enuntul+cerinte ?
Răspunsuri la întrebare
#include <iostream>
#include <cctype>
#include <cstring>
#include <stdlib.h>
#include <fstream>
#include <cstdlib>
#include <ctime>
using namespace std;
ifstream fin("teatru.txt");
ofstream fout("iesire.txt");
void citire(int m[11][11])
{
for(int i=1; i<=10; i++)
{for( int j=1; j<=10; j++)
{
fin>>m[i][j];
}
}
}
void afisare(int m[11][11])
{
for(int i=1; i<=10; i++)
{
for(int j=1; j<=10; j++)
{
fout<<m[i][j] << " ";
}
fout << "\n";
}
fout << "\n";
}
int vanzari_bilete(int m[11][11])
{
int s;
int i;
s=0;
for(i=2;i<=9;i++)
{
if(m[i][1]%2==1)
s=s+5;
if(m[i][10]%2==1)
s=s+5;
if(m[1][i]%2==1)
s=s+5;
if(m[10][i]%2==1)
s=s+5;
}
for(i=3;i<=8;i++)
{
if(m[i][2]%2==1)
s=s+10;
if(m[i][9]%2==1)
s=s+10;
if(m[2][i]%2==1)
s=s+10;
if(m[9][i]%2==1)
s=s+10;
}
for(i=4;i<=7;i++)
{
if(m[i][3]%2==1)
s=s+15;
if(m[i][8]%2==1)
s=s+15;
if(m[3][i]%2==1)
s=s+15;
if(m[8][i]%2==1)
s=s+15;
}
for(i=5;i<=6;i++)
{
if(m[i][4]%2==1)
s=s+20;
if(m[i][7]%2==1)
s=s+20;
if(m[7][i]%2==1)
s=s+20;
if(m[4][i]%2==1)
s=s+20;
}
return s;
}
int nr_participanti(int m[11][11])
{
int i;
int j;
int k;
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
if(m[i][j]== -2)
k++;
}
}
return 80-k;
}
void generareCifre(int &c1, int &c2, int &c3)
{
c1=rand()%9+1;
c2=rand()%9+1;
while (c2==c1) c2=rand()%9+1;
c3=rand()%9+1;
while (c3==c1 || c3==c2) c3=rand()%9+1;
fout << "au fost extrase cifrele castigatoare: " << c1 << " " << c2 << " " << c3 << "\n" ;
}
int castig(int c1,int c2, int c3, int m)
{
if (c1*100+c2*10+c3==m) return 1;
if (c1*100+c3*10+c1==m) return 1;
if (c2*100+c1*10+c3==m) return 1;
if (c2*100+c3*10+c1==m) return 1;
if (c3*100+c1*10+c2==m) return 1;
if (c3*100+c2*10+c1==m) return 1;
return 0;
}
void afisare2(int m[11][11])
{
int i; int j;
int c1=0,c2=0,c3=0, nrcastig=0;
srand ( time(NULL) );
generareCifre(c1,c2,c3);
fout << "bilete castigatoare: \n";
for(i=1;i<=10;i++)
{for(j=1;j<=10;j++)
{
if(m[i][j]>99 && castig(c1,c2,c3,m[i][j]))
{
fout << m[i][j] << " ";
++nrcastig;
}
}
}
fout << "\n" << " nr de bilete castigatoare= " << nrcastig<< "\n" << "\n";
}
void ordcresc(int m[11][11])
{
int i;
int j;
int aux;
for(i=2;i<9;i++)
{
for(j=i+1;j<10;j++)
{
if (m[1][i]>99 && m[1][j]>99)
{if(m[1][i]>m[1][j])
{
aux=m[1][i];
m[1][i]=m[1][j];
m[1][j]=aux;
}}
if (m[10][i]>99 && m[10][j]>99)
{if(m[10][i]>m[10][j])
{
aux=m[10][i];
m[10][i]=m[10][j];
m[10][j]=aux;
}}
}
}
afisare(m);
}
void orddescresc(int m[11][11])
{
int i; int j; int aux;
for(i=2;i<9;i++)
{
for(j=i+1;j<10;j++)
{
if (m[i][1]>99 && m[j][1]>99)
{if(m[i][1]<m[j][1])
{
aux=m[1][i];
m[i][1]=m[j][1];
m[j][1]=aux;
}}
if (m[i][10]>99 && m[j][10]>99)
{if(m[i][10]<m[j][10])
{
aux=m[i][10];
m[i][10]=m[j][10];
m[j][10]=aux;
}}
}
}
afisare(m);
}
int main()
{
int m[11][11],cerinta,z;
char x;
citire(m);
cout<<" Noua sala de spectacole ";
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"Doriti sa vizualizati meniul programului?"<<endl;
cout<<"DA : d"<<endl;
cout<<"NU : n"<<endl;
cin>>x;
if(x=='d')
{
cout<<" MENIU "<<endl<<endl;
cout<<"1) Aflarea sumei de bani pe urma vanzarii biletelor."<<endl;
cout<<"2) Aflati numarul de participanti la spectacol."<<endl;
cout<<"3) Care sunt biletele castigatoare si cate sunt acestea?"<<endl;
cout<<"4) Ordonati crescator biletele de pe primele randuri orizontale."<<endl;
cout<<"5) Ordonati descrescator biletele de pe primele randuri verticale "<<endl;
cout<<"6) Iesiti din meniu."<<endl;
cout<<endl;
cout<<"Cerinta dorita din meniu: ? ";
cin>>cerinta;
do {
switch(cerinta)
{ case 1:
system("cls");
fout << "Suma incasata: " << vanzari_bilete(m) << endl << endl;
break;
case 2:
system("cls");
fout << "nr de paricipanti= " << nr_participanti(m) << endl << endl;
break;
case 3:
system("cls");
afisare2(m);
break;
case 4:
system("cls");
fout << "\n Tablou cu prima si ultima linie ordonate crescator: \n" << "\n";
ordcresc(m);
break;
case 5:
{system("cls");
fout << "\n Tablou cu prima si ultima coloana ordonate descrescator: \n" << "\n";
orddescresc(m);
break;}
default:
if(cerinta!=6)
cout<<"Cerinta inexistenta"<<endl;
break;
}
if(cerinta!=6)
{ cout<< "1) Inapoi la meniu "<<endl;
cout<<"2) Iesire "<<endl;
cout<<"Introduceti cifra corespunzatoare: ";
cin>>z;
if(z==1)
{ system("cls");
cout<<" MENIU "<<endl<<endl;
cout<<"1) Aflarea sumei de bani pe urma vanzarii biletelor."<<endl;
cout<<"2) Aflati numarul de participanti la spectacol."<<endl;
cout<<"3) Care sunt biletele castigatoare si cate sunt acestea?"<<endl;
cout<<"4) Ordonati crescator biletele de pe primele randuri orizontale."<<endl;
cout<<"5) Ordonati descrescator biletele de pe primele randuri verticale. "<<endl;
cout<<"6) Iesiti din meniu."<<endl;
cout<<endl;
cout<<"Cerinta dorita din meniu: ";
cin>>cerinta;}
else
{if(z==2)
cerinta=6;
else
{ cout<<"Cerinta inexistenta!"<<endl;
system("pause");}}
}
} while( cerinta!= 6);
system("cls");}
else cout << "O zi buna...";
return 0;
}