View difference between Paste ID: P33znJ8b and 4brj35d8
SHOW: | | - or go back to the newest paste.
1
#include <fstream>
2
#include <iostream>
3
#include<fstream>
4
#include <string>
5
6
7
using namespace std;
8
9
int main()
10
{
11
    ifstream in("zolc.txt");
12
13
    int size = 500;
14
    char buf[size];
15
    unsigned int znaki[256];
16
    for(int i=0;i<256;i++) znaki[i]=0;
17
    char *znak_ptr;
18
    int ilosc_znakow = 0, ilosc_linijek = 0;
19
    while (in.getline(buf,size))
20
    {
21
        ilosc_linijek++;
22
        znak_ptr = buf;
23
        while (*znak_ptr != '\0')
24
        {
25
            int temp =(int) *znak_ptr;
26
            if (temp >= 65 || temp <= 90) temp = 32 + temp;
27
            if ( temp < 0) temp = 256 + temp;
28
            znaki[temp]+=1;
29
            znak_ptr++;
30
            ilosc_znakow++;
31
        }
32
    }
33
    cout << " Ilość linijek: " << ilosc_linijek << endl;
34
    cout << "Ilość znaków: " << ilosc_znakow << endl;
35
    for (int i = 97; i< 256; i++) cout << i << " : " << znaki[i] << endl;
36
    in.close();
37-
    ofstream out("zolc.txt"),ios::app);
37+
    ofstream out("zolc.txt",ios::app);
38
    //out << "ilość znaków : " << znaki[144] << endl;
39
    for (int i = 97; i < 256; i++)
40
    out << "Ilosc znakow " << char (i) << ": " << znaki[i] << endl;
41
    return 0;
42
}