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<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
#include<iostream>
#include<iomainp>
Using namespace std;
Int main()
{
Int a, b, x, y;
Std::cin>>a>>b>>x>>y;
Float m =a/6;
Int n =y/6;
Int p =y%6;
Float k= ((float) n +(float) p/10) ;
Float d=x/k;
Float f = b/m;
Std::cout<<std::fixed<<std::setprecision(1) <<k<<"\n";
Std::cout<<d<<"\n"<<f<<"\n";
If(d>f)
Std::cout<<"Eligible to win";
}
xxxxxxxxxx
#ifndef CMAC_H
#define CMAC_H
void AES_CMAC(unsigned char *key, unsigned char *input, int length,
unsigned char *mac);
#endif
xxxxxxxxxx
#include <iostream>
using namespace std;
int main()
{
cout << "## Program Menghitung Gaji Karyawan ##" << endl;
cout << "========================================" << endl;
cout << endl;
string nama;
char golongan;
int jam_kerja, upah_per_jam, total_upah;
// proses input
cout << "Nama Karyawan: ";
getline(cin,nama);
cout << "Golongan: ";
cin >> golongan;
cout << "Jumlah jam kerja: ";
cin >> jam_kerja;
// tentukan jumlah upah per jam berdasarkan golongan
switch (golongan) {
case 'A':
upah_per_jam = 5000;
break;
case 'B':
upah_per_jam = 7000;
break;
case 'C':
upah_per_jam = 8000;
break;
case 'D':
upah_per_jam = 10000;
break;
}
total_upah = jam_kerja * upah_per_jam;
// cek apakah jam kerja lebih dari 48 jam
if ( (jam_kerja - 48) > 0 ) {
total_upah = total_upah + ((jam_kerja - 48)*4000);
}
// proses output
cout << endl;
cout << nama << " menerima upah Rp." << total_upah << " per minggu";
cout << endl;
return 0;
}
xxxxxxxxxx
int playTheGame(int array[],int n)
{
int ans=0;
while(true)
{
int i,j,ctr=0;
for(i=0;i<n;i++)
{
if(array[i] & 1)
{
break;
}
else if(array[i]==0)
{
ctr++;
}
}
if(ctr==n)
{
return ans;
}
if(i==n)
{
for(j=0;j<n;j++)
{
array[j]=array[j]/2;
}
ans++;
}
for(j=i;j<n;j++)
{
if (array[j] & 1)
{
array[j]--;
ans++;
}
}
}
return ans;
}
Jack and jill
C++
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
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
float x, y;
double k1, k2, k3;
k1 = 5.0 / 7.0;
k2 = -5.0 / 7.0;
k3 = 5.0 / 3.0;
cout << "Enter X: ";
cin >> x;
cout << "Enter Y: ";
cin >> y;
if ((y <= (k1 * x + 5) && x<=0 && y>=0) || (y >= (k2 * x - 5) && x <= 0 && y <= 0) || (y >= (k3 * x - 5) && x>=3 && y <= 0))
cout << "Yes!";
else
cout << "No!";
}
xxxxxxxxxx
#include <bits/stdc++.h>
using namespace std;
struct DiemGk{
int MSSV, diem;
DiemGk *next;
};
int main()
{
int n, Dmin;
cin>>n>>Dmin;
DiemGk *newNode;
newNode = new(DiemGk);
DiemGk *head = newNode;
int i, k = 0;
for(i=1; i<n; i++) {
cin>>newNode->MSSV>>newNode->diem;
if(newNode->diem >= Dmin) k++;
newNode->next = new(DiemGk);
newNode = newNode->next;
}
cin>>newNode->MSSV>>newNode->diem;
if(newNode->diem >= Dmin) k++;
newNode->next = NULL;
cout<<"Tong so sinh vien tham du ky thi cuoi ky: "<<k<<"\n";
while(head!=NULL) {
if(head->diem >= Dmin) cout<<head->MSSV<<" "<<head->diem<<"\n";
head = head->next;
}
return 0;
}