Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool rimes(char* first_word, char* second_word, int n)
- {
- // int l1 = strlen(first_word), l2 = strlen(second_word);
- if((int)strlen(first_word) < n) return false;
- if((int)strlen(second_word) < n) return false;
- // cout << first_word+(strlen(first_word)-n) << endl << second_word+(strlen(second_word)-n);
- if(strcmp(first_word+(strlen(first_word)-n), second_word+(strlen(second_word)-n)) == 0)
- return true;
- else
- return false;
- }
- void problema6(const char *input_file, const char *output_file)
- {
- ifstream fin(input_file);
- ofstream fout(output_file);
- char s[4][101], v[4][100], elem[100];
- char chr[] = ".,?! ";
- unsigned int n;
- fin >> n;
- fin.get();
- for(unsigned int i = 0; i<4; i++)
- {
- fin.getline(s[i], 101);
- char *p;
- p = strtok(s[i], chr);
- while( p != NULL )
- {
- strcpy(elem, p);
- p = strtok(NULL, chr);
- }
- strcpy(v[i], elem);
- //fin.get();
- }
- if(rimes(v[0], v[1], n) == true && rimes(v[2], v[3], n) == true && rimes(v[0], v[2], n) == false && rimes(v[0], v[3], n) == false)
- fout << "A\n";
- else if(rimes(v[0], v[2], n) == true && rimes(v[1], v[3], n) == true && rimes(v[0], v[1], n) == false && rimes(v[0], v[3], n) == false)
- fout << "B\n";
- else if(rimes(v[0], v[3], n) == true && rimes(v[1], v[2], n) == true && rimes(v[0], v[1], n) == false && rimes(v[0], v[2], n) == false)
- fout << "C\n";
- else if(rimes(v[0], v[1], n) == true && rimes(v[0], v[2], n) == true && rimes(v[0], v[3], n) == true)
- fout << "D\n";
- else fout << "E\n";
- fin.close();
- fout.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement