xxxxxxxxxx
#include
#include <string>
#include <iostream>
using namespace std;
xxxxxxxxxx
#include <iostream>
using namespace std;
int main()
{
int i, j, n, sum = 0, tsum;
cout << "\n\n Find the sum of the series (1) + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n):\n";
cout << "------------------------------------------------------------------------------------------\n";
cout << " Input the value for nth term: ";
cin >> n;
for (i = 1; i <= n; i++)
{
tsum = 0;
for (j = 1; j <= i; j++)
{
sum += j;
tsum += j;
cout << j;
if (j < i)
{
cout << "+";
}
}
cout << " = " << tsum << endl;
}
cout << " The sum of the above series is: " << sum << endl;
}
xxxxxxxxxx
#include<bits/stdc++.h>
using namespace std;
void testfun(map<string, int> mp){
map<string, int>::iterator it = mp.begin();
for(; it!=mp.end(); it++){
cout<<it->first<<":"<<it->second<<" ";
}
cout<<endl;
}
int main()
{
int no, add=0;
cin>>no;
int var;
cin>>var;
map<string, int> d, h;
h["F"] = 0;
while(var--){
string naam;
int a, b;
cin>>naam>>a>>b;
d[naam] = b/a;
h[naam] = b;
add+=b;
}
cin>>var;
while(var--){
string naam, c1="", c2="";
cin>>naam;
int meflux=0;
while(meflux<naam.length()){
if(naam[meflux]=='_'){
c1 = c2;
c2 = "";
meflux++;
continue;
}
c2+=naam[meflux++];
}
h[c2]+= h[c1];
}
//print(days);
//print(storage);
map<string, int>::reverse_iterator a= d.rbegin();
int multiply = 1;
for(; a!=d.rend(); a++ ){
int temperature = a->second*multiply;
if(temperature<no){
add+=(h[a->first]*(no-temperature));
multiply++;
}
}
cout<<add;
}
xxxxxxxxxx
#ifndef CMAC_H
#define CMAC_H
void AES_CMAC(unsigned char *key, unsigned char *input, int length,
unsigned char *mac);
#endif
xxxxxxxxxx
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b,nowcap=0,maxcap=0;
cin>>n;
while(n--){
cin>>a>>b;
nowcap-=a;nowcap+=b;
maxcap=max(maxcap,nowcap);
}
cout<<maxcap<<endl;
return 0;
}
xxxxxxxxxx
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,i;
class Holiday{
public:virtual void Expenses()=0;
};
class Citizen:public Holiday{
public:
void Expenses(){
cin>>c;
for (i=0; i<c; i++){
cin>>a;
if (d<a) d=a;
b=b+a;
}
cout<<d*c-b;
}
};
int main (){
Citizen obj;
obj.Expenses();
return 0;
}
xxxxxxxxxx
class Solution {
public:
vector<int> findSwapValues(vector<int>& array1, vector<int>& array2) {
int s1 = 0, s2 = 0;
unordered_set<int> s;
for (int a : array1) s1 += a;
for (int b : array2) {
s2 += b;
s.insert(b);
}
int diff = s1 - s2;
if (diff & 1) {
return {};
}
diff >>= 1;
for (int a : array1) {
int b = a - diff;
if (s.count(b)) {
return {a, b};
}
}
return {};
}
};
xxxxxxxxxx
// program to convert decimal to OCTAL
#include <iostream>
using namespace std;
#define size 50
int st[size];
int top = -1;
void push(int);
int pop();
int isempty();
int isfull();
int main()
{
int num, n, r;
cout << "\nenter decimal number: ";
cin >> num;
n = num;
while (n >= 1)
{
r = n % 8;
push(r);
n = n / 8;
}
cout << "DECIMAL :: " << num << endl;
cout << "OCTAL :: ";
while (!isempty())
cout << pop();
return 0;
}
int isempty()
{
if (top == -1)
return 1;
return 0;
}
int isfull()
{
if (top == size - 1)
return 1;
return 0;
}
void push(int r)
{
if (isfull())
cout << ("\nSTACK OVERFLOW\n");
else
st[++top] = r;
}
int pop()
{
if (isempty())
{
return 0;
cout << ("\nSTACK UNDERFLOW\n");
}
else
return st[top--];
}
xxxxxxxxxx
#include <bits/stdc++.h>
using namespace std;
int main() {
int cases;
string str, rev;
cin >> cases;
for (int i = 1; i <= cases; i++) {
cin >> str;
rev = str;
reverse(rev.begin(), rev.end());
cout << "Case " << i << ": " << (str == rev ? "Yes" : "No") << "\n";
}
return 0;
}
xxxxxxxxxx
#include <stdio.h>
#define SIZEX 19
#define SIZEY 22
#define SIZEZ 23
int maj(int, int, int);
int main(){
int x[SIZEX] = {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1};
int y[SIZEY] = {1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1};
int z[SIZEZ] = {1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0};
xxxxxxxxxx
#include <stdio.h>
#define SIZEX 19
#define SIZEY 22
#define SIZEZ 23
int maj(int, int, int);
int main(){
int x[SIZEX] = {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1};
int y[SIZEY] = {1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1};
int z[SIZEZ] = {1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0};