Advertisement
Mizuhara_Chizuru

Coding Ninja Surya's Answers Lecture 3

Dec 28th, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.69 KB | None | 0 0
  1. Check Case
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6.     // Write your code here
  7.     char a;
  8.     cin>>a;
  9.     if(a>='A' && a<='Z')
  10.         cout<<"1";
  11.     else if(a>='a'&&a<='z')
  12.         cout<<"0";
  13.     else
  14.         cout<<"-1";
  15.     return 0;
  16. }
  17.  
  18. Number Pattern 1
  19.  
  20. #include<iostream>
  21. using namespace std;
  22.  
  23.  
  24. int main(){
  25.  
  26.        /*  Read input as specified in the question.
  27.     * Print output as specified in the question.
  28.     */int n,temp=1;
  29.     cin>>n;
  30.     for(int i=1;i<=n;i++)
  31.   {
  32.     temp=i;
  33.     for(int j=1;j<=i;j++)
  34.       {
  35.         cout<<temp;
  36.         temp++;
  37.       }
  38.     cout<<'\n';
  39.   }
  40.     return 0;
  41. }
  42.  
  43. #include<iostream>
  44. using namespace std;
  45.  
  46.  
  47. int main(){
  48.  
  49.        /*  Read input as specified in the question.
  50.     * Print output as specified in the question.
  51.     */
  52.     int n,temp;
  53.     cin>>n;
  54.   for(int i=1;i<=n;i++)
  55.   {
  56.     for(int j=i;j<=n-1;j++)
  57.         cout<<' ';
  58.     temp=i;
  59.     for(int j=1;j<=i;j++)
  60.       {
  61.         cout<<temp;
  62.         temp++;
  63.       }
  64.     cout<<'\n';
  65.   }
  66. }
  67.  
  68.  
  69.  
  70. #include<iostream>
  71. using namespace std;
  72.  
  73.  
  74. int main()
  75. {
  76.  
  77.   int n,temp=1;
  78.   cin>>n;
  79.   for(int i=0;i<n;i++)
  80.     {
  81.       for(int j=1;j<n-i;j++)
  82.         cout<<' ';
  83.       for(int j=1;j<=temp;j++)
  84.         cout<<'*';
  85.       temp+=2;
  86.       cout<<'\n';
  87.     }
  88.   return 0;
  89. }
  90.  
  91. /*Code by Surya a.k.a Sunny*/
  92. /* by https://www.codechef.com/users/spsc */
  93. #include <bits/stdc++.h>
  94. //#include <boost/multiprecision/cpp_int.hpp>
  95. #define lli long long
  96. #define pi 3.14159265358979323846
  97. #define MOD 1000000007
  98. #define unbuffer cin.clear(); cin.sync();
  99. #define foi(n)  for(lli i=0;i<n;i++)
  100. #define foj(n)  for(lli j=0;j<n;j++)
  101. #define test(T) lli T;cin>>T;while(T--)
  102. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  103. using namespace std;
  104. //using namespace boost::multiprecision;
  105. int main()
  106. {
  107.  
  108.   lli basic,ans2;
  109.   char grade;
  110.   double hra,df,pf,ans;
  111.  
  112.   cin>>basic>>grade;
  113.   hra=(.20)*basic;
  114.   df=(.50)*basic;
  115.   pf=(.11)*basic;
  116.   ans=basic+hra+df-pf;
  117.   if(grade=='A')
  118.     ans+=1700;
  119.   else if(grade=='B')
  120.     ans+=1500;
  121.   else
  122.     ans+=1300;
  123.   ans2=round(ans);
  124. cout<<ans2;
  125. }
  126.  
  127.  
  128. /*Code by Surya a.k.a Sunny*/
  129. /* by https://www.codechef.com/users/spsc */
  130. #include <bits/stdc++.h>
  131. //#include <boost/multiprecision/cpp_int.hpp>
  132. #define lli long long
  133. #define pi 3.14159265358979323846
  134. #define MOD 1000000007
  135. #define unbuffer cin.clear(); cin.sync();
  136. #define foi(n)  for(lli i=0;i<n;i++)
  137. #define foj(n)  for(lli j=0;j<n;j++)
  138. #define test(T) lli T;cin>>T;while(T--)
  139. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  140. using namespace std;
  141. //using namespace boost::multiprecision;
  142. int main()
  143. {
  144.   int n,temp,odd=0,even=0;
  145.   cin>>n;
  146.   while(n!=0)
  147.     {
  148.       temp=n%10;
  149.       if(temp%2)
  150.         odd+=temp;
  151.       else
  152.         even+=temp;
  153.       n/=10;
  154.     }
  155.     cout<<even<<' '<<odd;
  156.     return 0;
  157.  }
  158.  
  159.  
  160. /*Code by Surya a.k.a Sunny*/
  161. /* by https://www.codechef.com/users/spsc */
  162. #include <bits/stdc++.h>
  163. //#include <boost/multiprecision/cpp_int.hpp>
  164. #define lli long long
  165. #define pi 3.14159265358979323846
  166. #define MOD 1000000007
  167. #define unbuffer cin.clear(); cin.sync();
  168. #define foi(n)  for(lli i=0;i<n;i++)
  169. #define foj(n)  for(lli j=0;j<n;j++)
  170. #define test(T) lli T;cin>>T;while(T--)
  171. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  172. using namespace std;
  173. //using namespace boost::multiprecision;
  174. int main()
  175. {
  176.  
  177. lli n,m,temp;
  178. cin>>n>>m;
  179.     temp=n;
  180.     if(n==0)
  181.       {
  182.         if(m==0)
  183.           cout<<"1";
  184.         else
  185.           cout<<"0";
  186.       }
  187.       else
  188.       {
  189.         if(m==0)
  190.           cout<<"1";
  191.         else
  192.         {
  193.             while(--m)
  194.                 n*=temp;
  195.             cout<<n;
  196.         }
  197.         }
  198.     return 0;
  199.  }
  200.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement