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[]){
  9. int ind1 =0,ind2=0;
  10. for(int i =0;i<n;i++){
  11. if(arr[i].num == 1){
  12. p[i] = arr[i%n].f;
  13. q[i] = arr[i%n].s;
  14.  
  15. }
  16. else if(arr[i].num ==0){
  17. l[i] = arr[i%n].f;
  18. m[i] = arr[i%n].s;
  19. }
  20. else{
  21. p[i] = arr[i%n].f;
  22. q[i] = arr[i%n].f;
  23. l[i] = arr[i%n].f;
  24. m[i] = arr[i%n].f;
  25. }
  26. }
  27. /* for(int i =0;i<n;i++){
  28. cout<<p[i]<<q[i]<<l[i]<<m[i];
  29. }*/
  30. }
  31. void lower(char C){
  32. int asc = C;
  33. if(C>='A' && C<='Z'){
  34.  
  35. asc = asc+32;
  36. char clower;
  37. clower = asc;
  38. cout<<clower;
  39. }
  40. else if(C>='a' && C<='z')
  41. cout<<C;
  42.  
  43.  
  44. }
  45.  
  46. void lowerIntoUpp(char c){
  47. if(c>='a'&&c<='z'){
  48. c = c-32;
  49. cout<<c;
  50. }
  51. else if(c>='A'&&c<='Z'){
  52. cout<<c;
  53. }
  54. }
  55. void convert(string str){
  56. lowerIntoUpp(str[0]);
  57. for(int i = 1;i<str.length();i++){
  58. lower((str[i]));
  59. }
  60. }
  61. void convertx(field arr[], int n){
  62. string p[n], q[n], l[n], m[n];
  63. prints(arr, n, p, q, l, m);
  64. string b[4*n];
  65. int ind = 0;
  66. for(int i =0;i<n;i++){
  67. b[ind++] = p[i];
  68.  
  69. b[ind++] =q[i];
  70.  
  71. b[ind++] =l[i];
  72.  
  73. b[ind++] = m[i];
  74.  
  75. }
  76. for(int i =0;i<4*n;i++){
  77. convert(b[i]);
  78. cout<<" ";
  79.  
  80. }
  81. }
  82. int main() {
  83. // your code goes here
  84. int n;
  85. cin>>n;
  86. field arr[n];
  87. for(int i =0;i<n;i++){
  88. cin>>arr[i].f>>arr[i].s>>arr[i].num;
  89. }
  90. convertx(arr, n);
  91. return 0;
  92. }
Success #stdin #stdout 0.01s 5396KB
stdin
5
as4,n askd 1
ad ajd 1
sd kjdn 0
nd eejdn 0
sndd
stdout
Asn Askd   Ad Ajd     Sd Kjdn   Nd Eejdn Sndd Sndd Sndd Sndd