Current streak:
0 days
Longest streak:
9 days
Less
More
#include <bits/stdc++.h> void solve(stack<int>&inputStack, int count, int size) { //base case if(count == size/2) { inputStack.pop(); return ; } int num = inputStack.top(); inputStack.pop(); //RECURSIVE CALL solve(inputStack, count+1, size); inputStack.push(num); }
void deleteMiddle(stack<int>&inputStack, int N){ int count = 0; solve(inputStack, count, N); }
class ComplexNumbers {
// Complete this class
int Real;
int Imag;
public:
ComplexNumbers(int r, int i)
{
Real = r;
Imag = i;
}
void plus(ComplexNumbers const &c )
{
Real = Real + c.Real;
Imag = Imag + c.Imag;
}
void multiply(ComplexNumbers &c)
{
int temp1, temp2;
temp1 = Real*c.Real - Imag*c.Imag;
temp2 = Real*c.Imag + Imag*c.Real;
Real = temp1;
Imag = temp2;
}
void print()
{
cout<<Real<<" + "<<"i"<<Imag;
}
};
int solve(int *arr, int s, int e, int k) { if(s>e) return -1; int mid = s+ (e-s)/2; if(arr[mid] == k) { return mid; } if(arr[mid] < k) { return solve(arr, mid+1, e, k); } else { return solve(arr, s, mid-1, k); } }
int binarySearch(int *input, int n, int val) { //Write your code here int ans = solve(input, 0, n-1, val); }
#include <bits/stdc++.h> #include <iostream>
using namespace std;
//Write your totalPrime function here int totalPrime(int a, int b) { int i,j,flag,count=0; for(i=a; i<=b; i++) { flag = 0; for(j=2; j <= i/2; j++) { if(i%j==0) { flag=1; break; } } if(flag==0 && i>=2) { count++; } } return count; }
int main() { int S, E; cin >> S >> E; cout << totalPrime(S, E); return 0; }
#include <bits/stdc++.h> #include <iostream> using namespace std;
int main() { int basicSalary; char ch; cin>>basicSalary>>ch; float hra, da, pf; int allow; hra = 0.2*basicSalary; da = 0.5*basicSalary; pf = 0.11*basicSalary; int totalSalary = 0; if(ch == 'A') { allow = 1700; } else if (ch == 'B') { allow = 1500; } else { allow = 1300; } totalSalary = totalSalary + basicSalary+ hra + da + allow - pf; cout<<(int)round(totalSalary)<<endl;
return 0; }