Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ***************QUESTION 2 and 4 HAVE TWO answers*****************
- No Output
- 21345 21435
- 97531-1
- (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
- /*Code by Surya a.k.a Sunny*/
- /* by https://www.codechef.com/users/spsc */
- #include <bits/stdc++.h>
- //#include <boost/multiprecision/cpp_int.hpp>
- #define lli long long
- #define pb push_back
- #define eb emplace_back
- #define pi 3.14159265358979323846
- #define MOD 1000000007
- #define unbuffer cin.clear(); cin.sync();
- #define foi(n) for(lli i=1;i<=n;i++)
- #define foj(n) for(lli j=0;j<n;j++)
- #define test(T) lli T;cin>>T;while(T--)
- #define loop(i, a, b) for(int i = (a); i<= (b); i++)
- using namespace std;
- //using namespace boost::multiprecision;
- int main()
- {
- //ios_base::sync_with_stdio(false);
- //cin.tie(NULL);
- //cout.tie(NULL);
- int n;
- cin>>n;
- foi(n)
- {
- for(int j=n;j>i;j--)
- cout<<' ';
- for(int k=i;k>=1;k--)
- cout<<k;
- for(int l=2;l<=i;l++)
- cout<<l;
- cout<<'\n';
- }
- }
- /*Code by Surya a.k.a Sunny*/
- /* by https://www.codechef.com/users/spsc */
- #include <bits/stdc++.h>
- //#include <boost/multiprecision/cpp_int.hpp>
- #define lli long long
- #define pb push_back
- #define eb emplace_back
- #define pi 3.14159265358979323846
- #define MOD 1000000007
- #define unbuffer cin.clear(); cin.sync();
- #define foi(n) for(lli i=0;i<n;i++)
- #define foj(n) for(lli j=0;j<n;j++)
- #define test(T) lli T;cin>>T;while(T--)
- #define loop(i, a, b) for(int i = (a); i<= (b); i++)
- using namespace std;
- //using namespace boost::multiprecision;
- int main()
- {
- //ios_base::sync_with_stdio(false);
- //cin.tie(NULL);
- //cout.tie(NULL);
- int n;
- cin>>n;
- for(int i=n;i>0;i--)
- {
- for(int j=1;j<=n;j++)
- {
- if(j<=i)
- cout<<j;
- else
- cout<<'*';
- }
- for(int j=n;j>0;j--)
- {
- if(j<=i)
- cout<<j;
- else
- cout<<'*';
- }
- cout<<'\n';
- }
- }
- /*Code by Surya a.k.a Sunny*/
- /* by https://www.codechef.com/users/spsc */
- #include <bits/stdc++.h>
- #include <climits>
- //#include <boost/multiprecision/cpp_int.hpp>
- #define lli long long
- #define pb push_back
- #define eb emplace_back
- #define pi 3.14159265358979323846
- #define MOD 1000000007
- #define unbuffer cin.clear(); cin.sync();
- #define foi(n) for(lli i=0;i<n;i++)
- #define foj(n) for(lli j=0;j<n;j++)
- #define test(T) lli T;cin>>T;while(T--)
- #define loop(i, a, b) for(int i = (a); i<= (b); i++)
- using namespace std;
- //using namespace boost::multiprecision;
- int main()
- {
- //ios_base::sync_with_stdio(false);
- //cin.tie(NULL);
- //cout.tie(NULL);
- int n,temp=INT_MIN, temp2=INT_MIN,num,i=1;
- cin>>n;
- while(i<=n)
- {
- cin>>num;
- if(num>temp)
- {
- temp2=temp;
- temp=num;
- }
- else if(num>temp2&&num!=temp)
- {
- temp2=num;
- }
- i++;
- }
- cout<<temp2<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement