Advertisement
Mizuhara_Chizuru

Coding Ninja Surya's Answers Test 1

Jan 4th, 2022
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ***************QUESTION 2 and 4 HAVE TWO answers*****************
  2.  
  3.  
  4.  
  5. No Output
  6. 21345 21435
  7. 97531-1
  8. (a || b) && c is true if c is true and either a or b is true   a||b is true if either a or b is true
  9.  
  10.  
  11.  
  12.  
  13. /*Code by Surya a.k.a Sunny*/
  14. /* by https://www.codechef.com/users/spsc */
  15. #include <bits/stdc++.h>
  16. //#include <boost/multiprecision/cpp_int.hpp>
  17. #define lli long long
  18. #define pb push_back
  19. #define eb emplace_back
  20. #define pi 3.14159265358979323846
  21. #define MOD 1000000007
  22. #define unbuffer cin.clear(); cin.sync();
  23. #define foi(n)  for(lli i=1;i<=n;i++)
  24. #define foj(n)  for(lli j=0;j<n;j++)
  25. #define test(T) lli T;cin>>T;while(T--)
  26. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  27. using namespace std;
  28. //using namespace boost::multiprecision;
  29. int main()
  30. {
  31.   //ios_base::sync_with_stdio(false);
  32.    //cin.tie(NULL);
  33.   //cout.tie(NULL);
  34. int n;
  35. cin>>n;
  36. foi(n)
  37.   {
  38.     for(int j=n;j>i;j--)
  39.       cout<<' ';
  40.     for(int k=i;k>=1;k--)
  41.       cout<<k;
  42.     for(int l=2;l<=i;l++)
  43.       cout<<l;
  44.     cout<<'\n';
  45.   }
  46.  }
  47.  
  48.  
  49.  
  50.  
  51. /*Code by Surya a.k.a Sunny*/
  52. /* by https://www.codechef.com/users/spsc */
  53. #include <bits/stdc++.h>
  54. //#include <boost/multiprecision/cpp_int.hpp>
  55. #define lli long long
  56. #define pb push_back
  57. #define eb emplace_back
  58. #define pi 3.14159265358979323846
  59. #define MOD 1000000007
  60. #define unbuffer cin.clear(); cin.sync();
  61. #define foi(n)  for(lli i=0;i<n;i++)
  62. #define foj(n)  for(lli j=0;j<n;j++)
  63. #define test(T) lli T;cin>>T;while(T--)
  64. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  65. using namespace std;
  66. //using namespace boost::multiprecision;
  67. int main()
  68. {
  69.   //ios_base::sync_with_stdio(false);
  70.    //cin.tie(NULL);
  71.    //cout.tie(NULL);
  72.  
  73. int n;
  74. cin>>n;
  75. for(int i=n;i>0;i--)
  76. {
  77.   for(int j=1;j<=n;j++)
  78.   {
  79.     if(j<=i)
  80.       cout<<j;
  81.     else
  82.       cout<<'*';
  83.   }
  84.   for(int j=n;j>0;j--)
  85.   {
  86.     if(j<=i)
  87.       cout<<j;
  88.     else
  89.       cout<<'*';
  90.   }
  91.   cout<<'\n';
  92. }
  93. }
  94.  
  95.  
  96.  
  97. /*Code by Surya a.k.a Sunny*/
  98. /* by https://www.codechef.com/users/spsc */
  99. #include <bits/stdc++.h>
  100. #include <climits>
  101. //#include <boost/multiprecision/cpp_int.hpp>
  102. #define lli long long
  103. #define pb push_back
  104. #define eb emplace_back
  105. #define pi 3.14159265358979323846
  106. #define MOD 1000000007
  107. #define unbuffer cin.clear(); cin.sync();
  108. #define foi(n)  for(lli i=0;i<n;i++)
  109. #define foj(n)  for(lli j=0;j<n;j++)
  110. #define test(T) lli T;cin>>T;while(T--)
  111. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  112. using namespace std;
  113. //using namespace boost::multiprecision;
  114. int main()
  115. {
  116.   //ios_base::sync_with_stdio(false);
  117.    //cin.tie(NULL);
  118.    //cout.tie(NULL);
  119. int n,temp=INT_MIN, temp2=INT_MIN,num,i=1;
  120. cin>>n;
  121. while(i<=n)
  122. {
  123.   cin>>num;
  124.   if(num>temp)
  125.   {
  126.     temp2=temp;
  127.     temp=num;
  128.   }
  129.   else if(num>temp2&&num!=temp)
  130.   {
  131.     temp2=num;
  132.   }
  133.   i++;
  134. }
  135. cout<<temp2<<'\n';
  136. }
  137.  
Advertisement
RAW Paste Data Copied
Advertisement