Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. struct el_listy1{
  6.    char slowo[20];
  7.    struct el_listy1 *next;
  8. };
  9. struct el_listy2{
  10.    char slowo[20];
  11.    int czestosc;
  12.    struct el_listy2 *next;
  13. };
  14.  
  15. struct el_listy2 *przepisz(struct el_listy1 *lista){
  16.    struct el_listy2 *poczatek=NULL, *e=NULL, *koniec=NULL, *nowy;
  17.    while(lista!=NULL){
  18.       e=poczatek;
  19.       while(e!=NULL){
  20.          if(strcmp(e->slowo, lista->slowo)==0){
  21.             e->czestosc++;
  22.             break;
  23.          }
  24.          e=e->next;
  25.       }
  26.       if(e==NULL){
  27.          nowy=(struct el_listy2 *)malloc(sizeof(struct el_listy2));
  28.          nowy->next=NULL;
  29.          strcpy(nowy->slowo, lista->slowo);
  30.          nowy->czestosc=1;
  31.          if(poczatek==NULL){
  32.             poczatek=nowy;
  33.             koniec=nowy;
  34.          }
  35.          else{
  36.             koniec->next=nowy;
  37.             koniec=nowy;
  38.          }
  39.       }
  40.       lista=lista->next;
  41.    }
  42.    return poczatek;
  43. }
  44.  
  45. int main(){
  46.    
  47.    return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement