Advertisement
a53

fraze

a53
Feb 27th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3. #include<cmath>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char s[260],a[30],b[260],v[102][260];
  9. int i,j,n,ok,okp,p=0,x=0,y=0;
  10. ifstream in("fraze.in");
  11. ofstream out("fraze.out");
  12. a[0]='a';
  13. for(i=1;i<=25;i++)
  14. a[i]=a[i-1]+1;
  15. while(in.getline(s,260,'\n'))
  16. {
  17. strcpy(b,s);
  18. for (i=0;i<strlen(b);i++)
  19. if (b[i]>='A'&&b[i]<='Z') b[i]+=32;
  20. ok=1;
  21. okp=1;
  22. for(i=0;i<=25;i++)
  23. {
  24. p=0;
  25. for(j=0;j<=strlen(b)-1;j++)
  26. {
  27. if(a[i]==b[j])
  28. p++;
  29. if(p>2)
  30. break;
  31. }
  32. if(p==0)
  33. {
  34. ok=0;
  35. okp=0;
  36. }
  37. if(p>1)
  38. okp=0;
  39. }
  40. if(ok==1)
  41. {
  42. x++;
  43. for(i=0;i<=strlen(b);i++)
  44. v[x][i]=s[i];
  45. }
  46. if(okp==1)
  47. y++;
  48. }
  49. out<<x<<' '<<y<<'\n';
  50. do
  51. {
  52. ok=1;
  53. for(i=1;i<x;i++)
  54. if(strcmp(v[i],v[i+1])>0)
  55. {
  56. ok=0;
  57. strcpy(b,v[i]);
  58. strcpy(v[i],v[i+1]);
  59. strcpy(v[i+1],b);
  60. }
  61. }while(ok==0);
  62. for(i=1;i<=x;i++)
  63. out<<v[i]<<'\n';
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement