void Graph Delpoint int del int count FILE int GNew cout Ïîëó åííàÿ ìà

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
void Graph::Delpoint(int del, int count)
{
FILE *f;
int GNew[n][n] =
{
{0, 1, 1, 0},
{0, 0, 0, 0},
{0, 0, 0, 1},
{0, 1, 0, 0}
};
cout <<"Ïîëó÷åííàÿ ìàòðèöà â ôàéëå result.txt"<<endl;
if ((f = fopen("result.txt", "w")) == NULL)
{
cout << "Error" << endl;
system("pause >> void");
return;
}
for (i=del; i<n-count; i++)
for (j=0; j<n-count; j++)
GNew[i][j]=GNew[i+1][j];
for (j=del; j<n-count; j++)
for (i=0;i<n-count;i++)
GNew[i][j]=GNew[i][j+1];
for (i=0; i<n-1-count; i++)
{
for (j=0; j<n-1-count; j++)
fprintf(f,"%d ",GNew[i][j]);//cout<<" "<<GNew[i][j];
fprintf(f,"\n");//cout<<endl;
}
/*
for (i=0; i<n-count; i++)
{
for (j=0; j<n-count; j++)
{
GNew[i][j]=GM[i][j]
if (i!=del && j!=del)
fprintf(f,"%d ",GM[i][j]);
}
if (i!=del)
fprintf(f,"\n");
}*/
fclose(f);
}
int main(int argc, char *argv[])
{
setlocale(LC_ALL, "Rus");
int start=0,point,del=0,count=0;
bool *visited=new bool[n],*flag=new bool[n];
char filename[100];
if (argc == 1)
{
cout << "Ââåäèòå èìÿ ôàéëà" << endl;
cin >> filename;
}
else
strcpy(filename, argv[1]);
Graph U;
U.EnterMas(filename);
for (i=0; i<n; i++)
flag[i]=0;
cout<<"Çàäàéòå âåðøèíó: "<<endl; cin>>point;
while(k<n)
{
for (j=0; j<n; j++)
visited[j]=0;
cout<<"Ñòàðòîâàÿ âåðøèíà >> "; cout<< ++start<<endl;
cout<<"Ïîðÿäîê îáõîäà: ";
U.BFS(visited, start-1, point,flag);
}
for (i=0; i<n; i++)
if (flag[i]==0)
{
cout <<"Íóæíî óäàëèòü âåðøèíó " <<i+1<<endl;
del=i;
//U.Delpoint(del-count,count);
count++;
}
delete []visited;
delete []flag;
system("pause");
return 0;
}