Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. fstream plik;
  10. plik.open("Jabberwocky.txt", ios::in);
  11.  
  12. if (plik.good()==false)
  13. {
  14. cout<<"It doesnt exists";
  15. exit(0);
  16. }
  17.  
  18. string line;
  19. string contents[30];
  20. int line_nr=1;
  21. int tab[26];
  22. string indeks;
  23.  
  24. for (int i=0; i<26; i++)
  25. {
  26. tab[i]=0;
  27. indeks+=i+65; //dlaczego nie dziala indeks[i]=i+65?? jak robie tak i w tym samym forze daje cout<<indeks[i] to wyswietla ABC....
  28. //czy to ma zwiazek z dodawaniem stringow na zasadzie string = string 1 + string 2??
  29.  
  30.  
  31. }
  32.  
  33.  
  34. while(getline(plik,line))
  35. {
  36. contents[line_nr-1]=line;
  37. int l=contents[line_nr-1].length();
  38.  
  39. for (int i=0; i<l; i++)
  40. {
  41.  
  42. for (int j=0; j<26; j++)
  43. {
  44. if (indeks[j]==line[i])
  45. //tu i tak nie dziala ale wlasnie mam problem z tym
  46. //jak bym chciala sie dostac do contents[line_nr-1]od [i] to jak to zapisac
  47. //czy jest roznica teraz miedzy line a tym, to nie koniecznie do tego ale tez do nastepnych zadan
  48. //jak sobie zapisze tresc w tablicy stringo to jak sie dostac do poszczegolnych liter?
  49. //czy mam to wczytac jako macierz????
  50. {
  51.  
  52. tab[j]+=1;
  53. }
  54. }
  55.  
  56. }
  57.  
  58. line_nr++;
  59. }
  60.  
  61. plik.close();
  62.  
  63. for (int i=0; i<26; i++)
  64. {
  65.  
  66. cout<<endl<<indeks[i]<<": ";
  67. for (int j=0; j<tab[i]; j++)
  68. {
  69. cout<<"*";
  70. }
  71. }
  72.  
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement