mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-02 03:05:24 +08:00
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
50 lines
998 B
C
50 lines
998 B
C
/**
|
|
* File: vertex.h
|
|
* Created Time: 2023-10-28
|
|
* Author: krahets ([email protected])
|
|
*/
|
|
|
|
#ifndef VERTEX_H
|
|
#define VERTEX_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* 頂点の構造体 */
|
|
typedef struct {
|
|
int val;
|
|
} Vertex;
|
|
|
|
/* コンストラクタ:新しいノードを初期化する */
|
|
Vertex *newVertex(int val) {
|
|
Vertex *vet;
|
|
vet = (Vertex *)malloc(sizeof(Vertex));
|
|
vet->val = val;
|
|
return vet;
|
|
}
|
|
|
|
/* 値の配列を頂点の配列に変換する */
|
|
Vertex **valsToVets(int *vals, int size) {
|
|
Vertex **vertices = (Vertex **)malloc(size * sizeof(Vertex *));
|
|
for (int i = 0; i < size; ++i) {
|
|
vertices[i] = newVertex(vals[i]);
|
|
}
|
|
return vertices;
|
|
}
|
|
|
|
/* 頂点の配列を値の配列に変換する */
|
|
int *vetsToVals(Vertex **vertices, int size) {
|
|
int *vals = (int *)malloc(size * sizeof(int));
|
|
for (int i = 0; i < size; ++i) {
|
|
vals[i] = vertices[i]->val;
|
|
}
|
|
return vals;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // VERTEX_H
|