Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
h>
#include <stdlib.h>
#include <conio.h>
#include<string.h>
#include<windows.h>
SetConsoleTextAttribute(hcon,color);
int optiune,pl,i,k,n,m,y=0,x,j,p,a[50][50],v[50][50],virf[50][50],b,u,z,q,t,c[50],viz[50];
void nod(){
scanf(" %d",&n);
void citirelista(){
for(x=0;x<=n;x++){
for(y=0;y<=n+1;y++){
scanf("%d",&y);
if(y==0){break;}
if(x==y){
a[x][y]=2;}
else{a[x][y]=1;}
}
}
void citirema(){
for (x=0;x<=n;x++){
for (y=0;y<=n;y++){
scanf("%d",&a[x][y]);
void mat_ad(){
setcolor(12);
for (i=0;i<n+1;i++){
setcolor(12);
printf("\t[X%d]",i);
for (i=0;i<n+1;i++)
{ printf("\t");
printf("\n");
for(i=0;i<=n;i++){
setcolor(12);
printf("[X%d]\t",i);
for(j=0;j<=n;j++){
setcolor(14);
printf(" %d\t",a[i][j]);
}
printf("\n");
printf("\n");
void mat_in(){
for (i=0;i<n+1;i++){
setcolor(12);
printf("\t[X%d]",i);
for (i=0;i<n+1;i++){
printf("\t");
y=0;
memset(v, 0, sizeof(int)*50*50);
if (a[i][j]==1)
//memset(v[y], 0, 50);
v[y][i]=-1;
v[y][j]=1;
y++;
}
else if (a[i][j]==2)
v[y][i]=2;
y++;
printf("\n");
for(i=0;i<y;i++){
setcolor(12);
printf("[U%d]\t",i+1);
for(j=0;j<=n;j++){
setcolor(14);
printf(" %d\t",v[i][j]);
printf("\n");
printf("\n");
void lista_in(){
setcolor(12);
{ setcolor(12);
if (a[i][j]==1)
{ setcolor(14);
if (a[i][j]==2)
{ setcolor(14);
printf(" -1\n\n");
return;
void addvirf(){
k=1;
n++;
for (i=1;i<n-1;i++){
for (j=1;j<n-1;j++){
virf[i][j]=a[i][j];
for (i=1;i<n-1;i++){
for (j=1;j<n-1;j++){
a[i][j]=virf[i][j];
void addarc(){
scanf("%d",&x);
scanf("%d",&y);
if(x<=n&&y<=n){
a[x][y]=1;
if(x==y){
a[x][y]=2;
v[y][i]=2;
y++;
void delarc(){
a[x][y] = 0;
return;
for (i=0;i<m;i++) {
for (i=0;i<m;i++){
a[x][y]=a[x+1][y+1];
v[y][i]=v[y+1][i+1];
v[y][j]=v[y+1][j+1];
x=x-1;
y=y-1;
i=i-1;
j=j-1;
void delvirf(){
for (i=0;i<n;i++) {
for (j=0;j<n;j++){
a[j][p]=0;
a[i][p]=0;
a[p][j]=0;
void latime(){
int i,p,v,ii=1,jj=1;
c[1]=pl;
viz[pl]=1;
p=u=1;
while(p<=u){
v=c[p];
p++;
jj=1;
for(i=1;i<=n;i++){
if(a[v][i]==1 && viz[i]==0)
{u++;
c[u]=i;
viz[i]=1;}
void afisare_latime(){
setcolor(12);
for(i=1;i<=u;i++){
setcolor(14);
printf("%d ",c[i]);
printf("\n");
if (viz[pl]){
return;
printf("%d ",pl);
viz[pl]=1;
int j;
for(j=1;j<=n;j++){
if((a[pl][j]==1)){
adincime2(j);
}
memset(viz, 0, sizeof(viz));
adincime2(p);
int main(){
optiune=0;
int c=0;
setcolor(15);
printf("\
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º la Matematica discreta º\n\
º º\n\
º º\n\
º TEMA: º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
º º\n\
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ\n",185);
setcolor(3);
printf(" Doriti sa afisati MENU programului?\n Daca 'Da' tastati '1', daca 'Nu' tastati orice tasta: ");
scanf("%d",&c);
if(c==1){
do{
system("CLS");
setcolor(9);
printf("\
º\n\
º\n\
º\n\
º\n\
7. Toate. º\n\
º\n\
º\n\
º\n\
PARCURGEREA GRAFULUI º\n\
º\n\
º\n\
º\n\
0. Iesire. º\n\
\n",185);
setcolor(3);
scanf("%d",&optiune);
switch (optiune){
case 1: {nod();
setcolor(15);
system("PAUSE");
break;
case 2: {citirelista();
setcolor(15);
system("PAUSE");
break;
case 3: {citirema();
setcolor(15);
system("PAUSE");
break;
}
case 4: {mat_ad();
setcolor(15);
system("PAUSE");
break;
case 5: {mat_in();
setcolor(15);
system("PAUSE");
break;
case 6: {lista_in();
setcolor(15);
system("PAUSE");
break;
case 7: {
mat_ad();
mat_in();
lista_in();
setcolor(15);
system("PAUSE");
break;
case 8: {addvirf();
setcolor(15);
system("PAUSE");
break;
case 9: {addarc();
setcolor(15);
system("PAUSE");
break;
case 10: {
scanf("%d",&x);
scanf("%d",&y);
delarc();
setcolor(15);
system("PAUSE");
break;
case 11: {
int x=n;
scanf("%d",&p);
delvirf();
n=x;
system("PAUSE");
break;
case 12: {
for(i=1;i<=n;i++)viz[i]=0;
scanf("%d",&pl);
latime();
afisare_latime();
setcolor(15);
system("PAUSE");
break;
case 13: {
for(i=1;i<=n;i++)viz[i]=0;
scanf("%d",&pl);
setcolor(12);
setcolor(14);
adincime(pl);
printf("\n");
setcolor(15);
system("PAUSE");
break;
}
case 0:{
return 0;
default:{
setcolor(15);
system("PAUSE");
break;
while(optiune!=0);
getch();
return 0;
else{return 0;}