Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <stdio.h>
- using namespace std;
- int letter2num(char l)
- {
- if(l=='a') return 0;
- if(l=='b') return 1;
- if(l=='c') return 2;
- if(l=='d') return 3;
- if(l=='e') return 4;
- if(l=='f') return 5;
- if(l=='g') return 6;
- if(l=='h') return 7;
- if(l=='i') return 8;
- if(l=='j') return 9;
- if(l=='k') return 10;
- if(l=='l') return 11;
- if(l=='m') return 12;
- if(l=='n') return 13;
- if(l=='o') return 14;
- if(l=='p') return 15;
- if(l=='q') return 16;
- if(l=='r') return 17;
- if(l=='s') return 18;
- if(l=='t') return 19;
- if(l=='u') return 20;
- if(l=='v') return 21;
- if(l=='w') return 22;
- if(l=='x') return 23;
- if(l=='y') return 24;
- if(l=='z') return 25;
- if(l==',') return 26;
- if(l=='.') return 27;
- if(l== ' ') return 28;
- return 29;
- }
- void compare(string t1,string t2)
- {
- vector <int> v(30,0);
- vector <int> w(30,0);
- for(int i=0;i<t1.size();i++)
- {
- v[letter2num(t1[i])]+=1;
- }
- for(int i=0;i<t2.size();i++)
- {
- w[letter2num(t2[i])]+=1;
- }
- int letters=0;
- int punctuation=0;
- int spaces=0;
- for(int i=0;i<26;i++)
- {
- if(v[i] == w[i]) letters+=1;
- cout<<v[i]<<" "<<w[i]<<endl; //This shows the number of letters and symbols in both of them
- }
- if( (v[26] == w[26]) && (v[27] == w[27])) punctuation = 2;
- if( (v[28] == w[28]) ) spaces = 1;
- cout<<"They have same: ";cout<<letters<<endl;
- if(letters == 26) cout<<"letters ";
- if(punctuation == 2) cout<<"punctuation ";
- if(spaces == 1) cout<<"spaces ";
- }
- int main()
- {
- string t1, t2;
- /*cout<<"Text 1"<<endl;
- getline (cin, t1, '\n');
- cout<<endl <<"Text 2"<<endl;
- getline (cin, t2, '\n');*/
- t1 = "this text and the one beside it are equal. i wrote this one first, and then i gave it to my friend christian bok and asked him to generate a new text using every letter and every punctuation mark that i used in mine. the other text is his.";
- t2 = "micah lexier requested in advance that i reinvent his text. so i unknotted it and reknitted it into this very form, but then i began to think that his message had alredy resewn a touted art of genuine poetry. his eerie text was mine.";
- //Manual counting A's in #1: 11111 11111 111
- //Manual counting A's in #2: 11111 11111 11
- compare(t1,t2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement