Advertisement
DominikPasiut

Untitled

Nov 27th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. /*
  2.    
  3.     3. Napisać program zliczający w tablicy tab3, ilość wystąpień znaku wprowadzonego
  4.     z klawiatury.
  5.    
  6.      */
  7. #include<stdio.h>
  8. #include<string.h>
  9.  
  10.  
  11. int main(int argc, char* argv[])
  12. {
  13.     char tab1[20]={'A','l','a',' ','m','a',' ','k','o','t','a'};
  14.     char tab2[20]={'Z','o','s','i','a',' ','m','a',' ','p','s','a'};
  15.     char tab3[100]={NULL};
  16.     int y[50]={NULL};
  17.  
  18.     strncpy(tab3,tab1,strlen(tab2));
  19.     strcat(tab3,tab2);
  20.  
  21.     puts(tab3);
  22.  
  23.     for(int k=0; k < strlen(tab3); k++)
  24.     {
  25.  
  26.         y[tab3[k]]++;       //Problem z policzeniem ilośći wystąpień danego znaku :/
  27.     }
  28.  
  29.     for(int i=0; i < strlen(tab3); i++)
  30.         printf("%d. %d\n",i, y[i]);
  31.     return 0;
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement