Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main(){
- int contatore_a = 0;
- int contatore_b = 0;
- int contatore_c = 0;
- int contatore_d = 0;
- int contatore_e = 0;
- int contatore_f = 0;
- int contatore_g = 0;
- int contatore_h = 0;
- int contatore_i = 0;
- int contatore_j = 0;
- int contatore_k = 0;
- int contatore_l = 0;
- int contatore_m = 0;
- int contatore_n = 0;
- int contatore_o = 0;
- int contatore_p = 0;
- int contatore_q = 0;
- int contatore_r = 0;
- int contatore_s = 0;
- int contatore_t = 0;
- int contatore_u = 0;
- int contatore_v = 0;
- int contatore_w = 0;
- int contatore_x = 0;
- int contatore_y = 0;
- int contatore_z = 0;
- int lunghezza_file = 0;
- int contatore_simboli = 0;
- ifstream file1{"input_10.3.txt"};
- for (string line; getline(file1, line);){
- lunghezza_file += sizeof(line);
- for(int i = 0; i < line.size(); i++){
- if (line[i] == 'a' || line[i] == 'A'){
- contatore_a++;
- }
- if (line[i] == 'b' || line[i] == 'B'){
- contatore_b++;
- }
- if (line[i] == 'c' || line[i] == 'C'){
- contatore_c++;
- }
- if (line[i] == 'd' || line[i] == 'D'){
- contatore_d++;
- }
- if (line[i] == 'e' || line[i] == 'E'){
- contatore_e++;
- }
- if (line[i] == 'f' || line[i] == 'F'){
- contatore_f++;
- }
- if (line[i] == 'g' || line[i] == 'G'){
- contatore_g++;
- }
- if (line[i] == 'h' || line[i] == 'H'){
- contatore_h++;
- }
- if (line[i] == 'i' || line[i] == 'I'){
- contatore_i++;
- }
- if (line[i] == 'l' || line[i] == 'L'){
- contatore_l++;
- }
- if (line[i] == 'm' || line[i] == 'M'){
- contatore_m++;
- }
- if (line[i] == 'n' || line[i] == 'N'){
- contatore_n++;
- }
- if (line[i] == 'o' || line[i] == 'O'){
- contatore_o++;
- }
- if (line[i] == 'p' || line[i] == 'P'){
- contatore_p++;
- }
- if (line[i] == 'q' || line[i] == 'Q'){
- contatore_q++;
- }
- if (line[i] == 'r' || line[i] == 'R'){
- contatore_r++;
- }
- if (line[i] == 's' || line[i] == 'S'){
- contatore_s++;
- }
- if (line[i] == 't' || line[i] == 'T'){
- contatore_t++;
- }
- if (line[i] == 'u' || line[i] == 'U'){
- contatore_u++;
- }
- if (line[i] == 'v' || line[i] == 'V'){
- contatore_v++;
- }
- if (line[i] == 'w' || line[i] == 'W'){
- contatore_w++;
- }
- if (line[i] == 'x' || line[i] == 'X'){
- contatore_x++;
- }
- if (line[i] == 'y' || line[i] == 'Y'){
- contatore_y++;
- }
- if (line[i] == 'z' || line[i] == 'Z'){
- contatore_z++;
- } else{
- contatore_simboli++;
- }
- }
- }
- cout << "Percentuale a: " << float(contatore_a) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale b: " << float(contatore_b) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale c: " << float(contatore_c) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale d: " << float(contatore_d) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale e: " << float(contatore_e) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale f: " << float(contatore_f) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale g: " << float(contatore_g) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale h: " << float(contatore_h) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale i: " << float(contatore_i) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale j: " << float(contatore_j) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale k: " << float(contatore_k) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale l: " << float(contatore_l) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale m: " << float(contatore_m) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale n: " << float(contatore_n) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale o: " << float(contatore_o) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale p: " << float(contatore_p) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale q: " << float(contatore_q) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale r: " << float(contatore_r) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale s: " << float(contatore_s) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale t: " << float(contatore_t) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale u: " << float(contatore_u) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale v: " << float(contatore_v) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale w: " << float(contatore_w) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale x: " << float(contatore_x) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale y: " << float(contatore_y) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale z: " << float(contatore_z) / float(lunghezza_file) *100<< " %" <<endl;
- cout << "Percentuale altri simboli: " << float(contatore_simboli) / float(lunghezza_file) * 100 << " %" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment