Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- struct Node {
- int x;
- struct Node *next;
- };
- int main() {
- srand(time(NULL));
- struct Node *head;
- head = (Node*)malloc(sizeof(struct Node));
- head->x = (rand() % 9 + 1);
- printf("%d \n", head->x);
- struct Node *tail;
- tail = head;
- for (int i = 0;i<99;i++) {
- struct Node *tmp;
- tmp = (Node*)malloc(sizeof(struct Node));
- tmp->x = (rand() % 9 + 1);
- tail->next = tmp;
- tmp->next = NULL;
- tail = tmp;
- printf("%d\n", tmp->x);
- }
- //szukanie min
- int min = head->x;
- int count = 0;
- struct Node *temp = head;
- while(temp!=NULL){
- if (min>temp->x) {
- min = temp->x;
- count = 1;
- }
- else if (min == temp->x) {
- count++;
- }
- temp = temp->next;
- }
- printf("ilosc liczb: %d \n", count);
- while (head != NULL)
- {
- temp = head->next;
- free(head);
- head = temp;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement