fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<string.h>
  4.  
  5. void zliczanie(char* tekst,char* alfabet,int* ilosc_liter)
  6. {
  7. int dlugosc_tekstu=strlen(tekst);
  8.  
  9. printf("Dlugosc podanego stringa to %d\n",dlugosc_tekstu);
  10. for(int i=0; i<=dlugosc_tekstu-1; ++i)
  11. {
  12. for(int j=0; j<52; ++j)
  13. {
  14. if(*(tekst+i)==*(alfabet+j)) *(ilosc_liter+j)+=1;
  15. }
  16. }
  17. }
  18.  
  19. int main()
  20. {
  21. int ilosc_liter[53]={0}, ile_testow;
  22. char alfabet [53]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  23. char tekst[101];
  24.  
  25. printf("Podaj ile testow:");
  26. scanf("%d",&ile_testow);
  27. for(int i=0; i<ile_testow; ++i)
  28. {
  29. printf("Podaj tekst:\n");
  30. gets(tekst);
  31. if(tekst!=NULL)
  32. {
  33. printf("Podales: %s\n",tekst);
  34. zliczanie(tekst,alfabet,ilosc_liter);
  35. printf("Ilosc wystapien litery w podanym zdaniu to:\n");
  36. for(int i=0; i<52; ++i)
  37. {
  38. if(*(ilosc_liter+i)>0) printf("%c:%d\n",*(alfabet+i),*(ilosc_liter+i));
  39. else continue;
  40. }
  41. }
  42. else
  43. {
  44. printf("Nie udalo sie odczytac tekstu!");
  45. return 0;
  46. }
  47. }
  48. return 0;
  49. }
  50.  
  51.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
Podaj ile testow: