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(){
- struct Node *head;
- head = malloc(sizeof(struct Node));
- head->x = (rand() % 9 + 1 );
- printf("%d \n", head->x);
- struct Node *tail;
- tail=head;
- struct Node *tmp;
- tmp = malloc(sizeof(struct Node));
- for (int i=0;i<99;i++){
- 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;
- for(int i=0; i<100; i++){
- if(min>temp->x){
- min=temp->x;
- count=1;
- }
- else if (min == temp->x){
- count++;
- }
- temp=temp->next;
- }
- printf("ilosc liczb: %d \n", count);
- free(head);
- free(tail);
- free(temp);
- free(tmp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement