teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

ちょい修正

2020/06/25 06:41

投稿

asm
asm

スコア15149

answer CHANGED
@@ -10,16 +10,23 @@
10
10
  あとは枝読み込み時を
11
11
 
12
12
  ```c
13
+ //点ラベル対(枝)を読み込み
14
+ for(i=0;i<n;i++){
15
+ scanf("%c%*c %c%*c",&c1,&c2);
16
+ int C1,C2;
17
+ for(C1=0; C1 < n && grp.vset[C1].label != c1;) C1++;
18
+ for(C2=0; C2 < n && grp.vset[C2].label != c2;) C2++;
13
- ed[i*2].next = NULL;
19
+ ed[i*2].next = NULL;
14
- ed[i*2].label = c2;
20
+ ed[i*2].label = c2;
15
- ed[i*2+1].next = NULL;
21
+ ed[i*2+1].next = NULL;
16
- ed[i*2+1].label = c1;
22
+ ed[i*2+1].label = c1;
17
23
 
18
- struct edge **np;
24
+ struct edge **np;
19
- for( np = &grp.vset[c1].link; *np != NULL; np = &np->next) ;
25
+ for( np = &grp.vset[C1].link; *np != NULL;) np = &(*np)->next;
20
- *np = &ed[i*2];
26
+ *np = &ed[i*2];
21
- for( np = &grp.vset[c2].link; *np != NULL; np = &np->next) ;
27
+ for( np = &grp.vset[C2].link; *np != NULL;) np = &(*np)->next;
22
- *np = &ed[i*2+1];
28
+ *np = &ed[i*2+1];
29
+ }
23
30
  ```
24
31
 
25
32
  に変更するだけですね