Professional Documents
Culture Documents
Code Lập Trình C Cơ Bản
Code Lập Trình C Cơ Bản
h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
int ID;
char name[128];
char school[128];
Node;
p -> ID = ID;
return p;
char* token;
// printf ( “%d”, ID );
int i = 1;
break;
if ( i == 1 )
else if ( i == 2 )
else if ( i == 3 )
else if ( i == 4 )
case 4:
i++;
int main()
int N;
int i = 0;
while ( i < N )
char* line;
i ++;
return 0;
}
REMAKE:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int ID;
char name[128];
char school[128];
} Node;
Node* makeNode(int ID, char* name, char* school, int idLeft, int idRight){
Node* p = (Node*)malloc(sizeof(Node));
p->ID = ID;
strcpy(p->name, name);
strcpy(p->school, school);
p->iDOfRight = -1;
p->iDOfLeft = -1;
return p;
Node* root;
//printf("!%s!", line);
int n = strlen(line);
char* token;
int ID ;
int i = 0;
char* name;
char* school;
while(token != NULL){
if(i == 0){
ID = atoi(token);
name = (char*)malloc(lengthOfName*sizeof(char));
strcpy(name, token);
school = (char*)malloc(lengthOfSc*sizeof(char));
strcpy(school, token);
iDOfLeft = atoi(token);
}
else if(i == 4){
iDOfRight = atoi(token);
i++;
//bằng p->ID
int main()
int N;
scanf("%d", &N);
int i = 0;
char line[128];
scanf("%s", line);
if(root == NULL){
root = readLine(line);
else{
Node* p = readLine(line);
findFather(p);//hàm này tìm ra nút cha của nút p và gán p làm con trái
//hoặc con phải của nút cha đó.
//printf("!%s!", line);
i++;
return 0;