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<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 <stdio.h>
int main()
{
/* printf function displays the content that is
* passed between the double quotes.
*/
printf("Hello World");
return 0;
}
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 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 <iostream>
#include <string>
using namespace std;
float timeTaken(float dist, float sp, int totalLaps){
return (dist /sp ) * totalLaps;
}
int main(){
int NumberOfLaps;
float distanceOfOneLap, speed;
string directionOfOneLap;
cout<<"Enter the total of laps: ";
cin>>NumberOfLaps;
cout<<"Enter the distance of one lap: ";
cin>>distanceOfOneLap;
cout<<"Enter the speed of one lap: ";
cin>>speed;
cout<<"Enter the direction. It must N, E, W, or S: ";
cin>>directionOfOneLap;
cout<<"\nTime Taken: "<<timeTaken(distanceOfOneLap, speed, NumberOfLaps)<<endl;
cout<<"Direction: "<<directionOfOneLap<<endl;
return 0;
}