Advertisement
Guest User

Atestat 35

a guest
Feb 9th, 2015
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. char s[256],a[50][50],*p;
  8. int n;
  9.  
  10. ifstream f("text.in")
  11. ofstream g("rime.out")
  12.  
  13. int main()
  14. {
  15.     f.getline(s,256);
  16.     p=strtok(s," ");
  17.     n=0;
  18.     while(p!=NULL)
  19.     {
  20.         strcpy(a[n],p);
  21.         n++;
  22.         p=strtok(NULL," ");
  23.     }
  24.     for(int i=0;i<n-1;i++)
  25.         for(int j=i+1;j<n;j++)
  26.             if(a[i][strlen(a[i])-1]==a[j][strlen(a[j])-1] && a[i][strlen(a[i])-2]==a[j][strlen(a[j])-2])
  27.         g<<a[i]<<" "<<a[j]<<endl;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement