Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <fstream>
- using namespace std;
- int main()
- {
- fstream plik;
- plik.open("Jabberwocky.txt", ios::in);
- if (plik.good()==false)
- {
- cout<<"It doesnt exists";
- exit(0);
- }
- string line;
- string contents[30];
- int line_nr=1;
- int tab[26];
- string indeks;
- for (int i=0; i<26; i++)
- {
- tab[i]=0;
- 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....
- //czy to ma zwiazek z dodawaniem stringow na zasadzie string = string 1 + string 2??
- }
- while(getline(plik,line))
- {
- contents[line_nr-1]=line;
- int l=contents[line_nr-1].length();
- for (int i=0; i<l; i++)
- {
- for (int j=0; j<26; j++)
- {
- if (indeks[j]==line[i])
- //tu i tak nie dziala ale wlasnie mam problem z tym
- //jak bym chciala sie dostac do contents[line_nr-1]od [i] to jak to zapisac
- //czy jest roznica teraz miedzy line a tym, to nie koniecznie do tego ale tez do nastepnych zadan
- //jak sobie zapisze tresc w tablicy stringo to jak sie dostac do poszczegolnych liter?
- //czy mam to wczytac jako macierz????
- {
- tab[j]+=1;
- }
- }
- }
- line_nr++;
- }
- plik.close();
- for (int i=0; i<26; i++)
- {
- cout<<endl<<indeks[i]<<": ";
- for (int j=0; j<tab[i]; j++)
- {
- cout<<"*";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement