Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Node{
- int value;
- struct Node *leftNode, *rightNode;
- } Node;
- struct Node *createNode(struct Node* localNode, int value){
- if(localNode == NULL){ //Создаем новый узел
- localNode = (struct Node *)malloc(sizeof(struct Node));
- localNode->rightNode = NULL;
- localNode->leftNode = NULL;
- localNode->value = value;
- } else if(value > localNode->value){
- localNode->rightNode = createNode(localNode->rightNode, value);
- } else if(value < localNode->value){
- localNode->leftNode = createNode(localNode->leftNode, value);
- }
- return localNode;
- }
- int countMax(struct Node *tree, int size){
- // int max = 0;
- // for(int i =0; i<)
- printf("%d", size);
- }
- int main(void) {
- struct Node *tree = NULL;
- int numbersArray[5000], inputNum, size;
- for(int i =0; i<5000;i++){
- scanf("%d", &inputNum);
- if(inputNum == 0){
- size = i-1;
- break;
- }
- numbersArray[i] = inputNum;
- }
- for(int i = 0;i<size;i++){
- tree = createNode(&tree, i);
- }
- printf("%d", countMax(&tree, size));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement