fork download
  1. #include <iostream>
  2. using namespace std;
  3. struct field{
  4. string f;
  5. string s;
  6. int num;
  7. };
  8. string b[100];
  9. void prints(field arr[], int n, string p[], string q[], string l[], string m[]){
  10. int ind =0;
  11. for(int i =0;i<n;i++){
  12. if(arr[i].num == 1){
  13. p[i] = arr[i%n].f;
  14. b[ind++] = p[i];
  15. q[i] = arr[i%n].s;
  16. b[ind++] = q[i];
  17.  
  18. }
  19. else if(arr[i].num ==0){
  20. l[i] = arr[i%n].f;
  21. b[ind++] = l[i];
  22. m[i] = arr[i%n].s;
  23. b[ind++] = m[i];
  24. }
  25. else{
  26. p[i] = arr[i%n].f;
  27. b[ind++] = p[i];
  28. q[i] = arr[i%n].f;
  29. b[ind++] = q[i];
  30. l[i] = arr[i%n].f;
  31. b[ind++] = l[i];
  32. m[i] = arr[i%n].f;
  33. b[ind++] = m[i];
  34. }
  35. }
  36. /* for(int i =0;i<n;i++){
  37. cout<<p[i]<<q[i]<<l[i]<<m[i];
  38. }*/
  39. }
  40. void find(field arr[], int n){
  41. string r[4*n];
  42. for(int i = 0;i<4*n;i++){
  43. for(int j = i+1;j<4*n;j++){
  44. if(b[i]==b[j]){
  45. b[i] = "remove";
  46. }
  47. }
  48. }
  49. for(int i = 0;i<4*n;i++){
  50. if(b[i]!= "remove")
  51. r[i]= b[i];
  52. }
  53. for(int i =0;i<4*n;i++)
  54. cout<<r[i]<<" ";
  55.  
  56. }
  57. void lower(char C){
  58. int asc = C;
  59. if(C>='A' && C<='Z'){
  60.  
  61. asc = asc+32;
  62. char clower;
  63. clower = asc;
  64. cout<<clower;
  65. }
  66. else if(C>='a' && C<='z')
  67. cout<<C;
  68.  
  69.  
  70. }
  71.  
  72. void lowerIntoUpp(char c){
  73. if(c>='a'&&c<='z'){
  74. c = c-32;
  75. cout<<c;
  76. }
  77. else if(c>='A'&&c<='Z'){
  78. cout<<c;
  79. }
  80. }
  81. void convert(string str){
  82. lowerIntoUpp(str[0]);
  83. for(int i = 1;i<str.length();i++){
  84. lower((str[i]));
  85. }
  86. }
  87. void convertx(field arr[], int n){
  88. string p[n], q[n], l[n], m[n];
  89.  
  90. int ind = 0;
  91.  
  92. for(int i =0;i<4*n;i++){
  93. convert(b[i]);
  94. cout<<" ";
  95.  
  96. }
  97. }
  98. void print(field arr[], int n){
  99. convertx(arr, n);
  100. find(arr, n);
  101. }
  102. int main(){
  103. int n;
  104.  
  105. cin>>n;
  106. field arr[n];
  107. for(int i =0;i<n;i++){
  108. cin>>arr[i].f>>arr[i].s>>arr[i].num;
  109. }
  110.  
  111. print(arr, n);
  112. return 0;
  113. }
  114.  
Success #stdin #stdout 0.01s 5476KB
stdin
6
Jo4e Ma,ry 1
ElizaBet5h June 1
Joe John 0
Joe, JuNe 0
John JUne 1
Margaret
stdout