-
Notifications
You must be signed in to change notification settings - Fork 0
/
pager_2012_one.c
87 lines (77 loc) · 2.15 KB
/
pager_2012_one.c
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
84
85
86
87
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/**
* 一个有向图,顶点存储在G[0..n-1]中,用领接表存储,判断是否有拓扑排序
*
*/
typedef struct edge // 边结点
{
int adjvex; // 改边的终止结点在顶点结点中的位置
struct edge *next;
}ELink;
typedef struct ver{ // 顶点信息
int indegree; // 记录入度
int data; // 顶点的数据信息
ELink *link; // 指向第一个边结点
}Vlink;
// 检测是不是拓扑排序
int TOPO_TEST(Vlink G[],int n,int V[]){
ELink *p;
int i ,k;
for ( i = 0; i < n; i++) // 控制V【n】 的数据,依次遍历
{
for ( k = 0; i < n; i++) // 控制G【n】的数据,依次遍历
{
if (G[k].data==V[i]) // 表示如果 v[i]的信息是G[k]的信息,表示两个顶点的信息相同
{
if (G[k].indegree!=0) // 判断是不是入度为0 。如果不是0 这表示不是拓扑排序
{
return 0;
}
p=G[k].link; // 指向下一个顶点信息
while (p!=NULL) // 循环 G[k]所指的所有邻接表的顶点的入度减去1
{
G[p->adjvex].indegree--; // 表示下一个顶点的入度减去1;
p=p->next;
}
break; // 表示一个顶点处理结束,立马结束,进行下一个V【i】顶点
}
}
}
}
int fun(char *s,char *t){
puts(s);
puts(t);
while (*t&&*s&&*s==*t)
{
s++;
t++;
}
puts(s);
puts(t);
printf("%d\n",*s);
printf("%d\n",*t);
printf("%d\n",strlen(s));
printf("%d\n",strlen(t));
return *s-*t;
}
int main(int argc, char const *argv[])
{
// int x=6;
// x+=x-=x*x;
// printf("%d\n",x);
// char *p,*q;
// p=(char *)malloc(sizeof(char)*20);
// q=p;
// scanf("%s%s",p,q);
// printf("p=%sq=%s\n",p,q);
// int a,k=3;
// a=++ABC(k+1);
// printf("%d,k=%d\n",a,k);
char s[20]={"zhanghskghskg"};
char b[10]={"hahah"};
int a =fun(s,b);
printf("%d\n",a);
return 0;
}