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