Sunteți pe pagina 1din 8

# #include"stdlib.

h"
#include"iostream.h"
#include"conio.h"
#include"math.h"
#include"fstream.h"
main()
{
system("cls");
ofstream out("textzz.txt");
float A[20][20];
int AA[20];
int BB[20];
int z,t,i,j,n,p=0,b,o,k,r,s,k1,r1,nm,w,po,pp,d,ee=0;
cout<<"\n\n\t\t Lucrare de laborator nr.1 la Matematica discreta";
cout<<"\n Dam numarul de varfuri: n= ";
out<<"\n Dam numarul de varfuri: n= ";
cin>>n;
out<<n;
n=n+1;
cout<<"\n Introducem legaturile \n";
out<<"\n Introducem legaturile \n";
for(i=1;i<n;i++){
for(j=1;j<n;j++) {
cout<<"x"<<i<<"x"<<j<<" "; /*indicator optic*/
out<<"x"<<i<<"x"<<j<<" ";
cin>>A[i][j];
out<<A[i][j]; }}
eticheta:

n=n+ee;
ee=0;
cout<<"\n

meniu";

out<<"\n

meniu";

cout<<"\n

1: Matriciea de incidenta";

out<<"\n

1: Matriciea de incidenta";

out<<"\n

cout<<"\n

out<<"\n

cout<<"\n

out<<"\n

cout<<"\n

out<<"\n

cout<<"\n

out<<"\n

cout<<"\n

cout<<"\n

7: Iesire";

out<<"\n

7: Iesire";

out<<"\n

cout<<"\n

## Alegeti optiunea convenabila si tastati enter:\n";

cin>>nm;
out<<nm;
switch(nm) {case 1 : { cout<<"\n\n Afisarea matricei de incidenta:\n";
out<<"\n\n Afisarea matricei de incidenta\n";
cout<<" |";

## /* element pentru regularea matriciei desenate*/

out<<" |";
for(r=1;r<n;r++){
cout<<"x"<<r<<"|"; /*pu. a ne arata cu care varf este legatura*/

out<<"x"<<r<<"|";}
for(i=1;i<n;i++){
cout<<"\n";
out<<"\n";
cout<<"----";

## /*a indrepta desenu*/

out<<"----";
for(k=1;k<n;k++){
cout<<"----";

## /*pentru a desena kletka*/

out<<"----";}
cout<<"\nx"<<i<<"| ";

## /*elementu de la kare porneste*/

out<<"\nx"<<i<<"| ";
for(j=1;j<n;j++){
cout<<A[i][j]<<"| " ;
out<<A[i][j]<<"| " ;}}
cout<<"\ndaca doriti sa schimbati varianta alesa tastati tasta 0";
out<<"\ndaca doriti sa schimbati varianta alesa tastati tasta 0 ";
cin>>w;
out<<w;
if(w==1){
return 0;}
if(w!=1){system("cls");
goto eticheta;}}

case 3 : {cout<<"\n\n\nlist!";
out<<"\n\n\nlist!";
for(i=1;i<n;i++){
out<<"\nx"<<i<<" "; /*trasarea liniea ce desparte varful principal de sec.*/
cout<<"\nx"<<i<<" ";

for(j=1;j<n;j++){
if(A[i][j]!=0){
out<<j<<" " ;
cout<<j<<" " ;}}
out<<"0";
cout<<"0";}
out<<"\ndaca doriti sa schimbati varianta alesa tastati tasta 0";
cout<<"\ndaca doriti sa schimbati varianta alesa tastati tasta 0";
cin>>w;
out<<w;
if(w==1){
return 0;}
if(w!=1){system("cls");
goto eticheta;}
}
case 2 :{ cout<<"\n\Afisam matricea de adiacenta:\n";
k=0;
p=0;
for(i=1;i<n;i++){
for(j=1;j<n;j++){
if(A[i][j]!=0){
k++;
AA[k]=i;
BB[k]=j;
p++;}} }
cout<<" "<<" |";
out<<" "<<"|";

k=0;
for(o=1;o<n;o++){
cout<<" x"<<o<<"|";
out<<" x"<<o<<"|";}
for(s=1;s<p+1;s++){
k++;
cout<<"\n";
out<<"\n";
for(o=1;o<n+1;o++){
cout<<"----";
out<<"----";}
cout<<"\nu"<<s<<"|";
out<<"\nu"<<s<<"|";
b=0;
k1=AA[k];
r1=BB[k];
for(o=1;o<n;o++){
if(k1==r1){if(k1==o){b=2;}if(k1!=o){b=0;}}
if(k1!=r1){if(k1==o){b=-1;}if(k1!=o){b=0;}if(r1==o){b=1;}}
if(b<0) {
cout<< b<<" |";
out<< b<<" |";}
if(b>=0){
cout<<" "<<b<<" |";
out<<" "<<b<<" |";}}}
cout<<"\ndaca doriti sa schimbati varianta alesa tastati tasta 0";
out<<"\ndaca doriti sa schimbati varianta alesa tastati tasta 0";
cin>>w;

out<<w;
if(w==1){
return 0;}
if(w!=1){
system("cls");
goto eticheta;}}
case 4: {cout<<"\n alegeti virfurile intre care doriti sa faceti modifikari\n";
cin>>po;
cin>>pp;
i=po;
j=pp;
cout<<"dam noua valoare legaturii ";
cout<<"x"<<i<<"x"<<j;
cin>>A[i][j];
system("cls");
goto eticheta;}
case 5: {for(i=n;i<n+1;i++){
for(j=1;j<n+1;j++) {
cout<<"x"<<i<<"x"<<j<<" "; /*indikator optik*/
cin>>A[i][j];}}
for(i=1;i<n;i++){
for(j=n;j<n+1;j++) {
cout<<"x"<<i<<"x"<<j<<" "; /*indikator optik*/
cin>>A[i][j];}}
ee=1;
goto eticheta; }
case 7: {cout<<"Sunteti sigur ca doriti sa iesiti? Daca da, tastati 1.";
cin>>w;

if(w==1){
return 0;}
if(w!=0){
system("cls");
goto eticheta;} }
case 6: { cout<<" Pe care varf doriti sa-l evitati?";
cin>>d;
i=d;
for(j=1;j<n;j++) {
A[i][j]=NULL;}
j=d;
for(i=1;i<n;i++);
{
A[i][j]=NULL;}
goto eticheta; }
default: {system("cls");
cout<<"Alegeti optiunea corecta";
goto eticheta;
}}
out.close();

return 0;
}

## Concluzie : Efectund aceast lucrare de laborator,am opinut cunotine despre modul de

pstrare a unui graf n memoria calculatorului i proprietile fiecrei forme n ceea ce ine de
volumul memoriei necesare i greutatea prelucrrii acestora acestea find principiile de baz
conform crora se alege metoda cea mai prielnic de implementare