Problema 1001
#include <iostream>
using namespace std;
int main() {
int x, y;
while(cin >> x){
cin >> y;
cout << "X = " << x + y << endl;
}
return 0;
}
Problema 1005
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
float a, b, res;
cin >> a >> b;
res = (3.5*a+7.5*b)/11;
printf("MEDIA = %.5f\n",res);
}
Problema 1021
#include <iostream>
using namespace std;
int main(){
int moe, nota;
float f;
while(cin >> f)
{
nota = f;
f = 100*f;
moe = f;
moe = moe%100;
cout << "NOTAS:" << endl;
cout << nota/100 << " nota(s) de R$ 100.00" << endl;
nota = nota%100;
cout << nota/50 << " nota(s) de R$ 50.00" << endl;
nota = nota%50;
cout << nota/20 << " nota(s) de R$ 20.00" << endl;
nota = nota%20;
cout << nota/10 << " nota(s) de R$ 10.00" << endl;
nota = nota%10;
cout << (nota/5) << " nota(s) de R$ 5.00" << endl;
nota = nota%5;
cout << nota/2 << " nota(s) de R$ 2.00" << endl;
nota = nota%2;
cout << "MOEDAS:" << endl;
cout << nota << " moeda(s) de R$ 1.00" << endl;
cout << moe/50 << " moeda(s) de R$ 0.50" << endl;
moe = moe%50;
cout << moe/25 << " moeda(s) de R$ 0.25" << endl;
moe = moe%25;
cout << moe/10 << " moeda(s) de R$ 0.10" << endl;
moe = moe%10;
cout << moe/5 << " moeda(s) de R$ 0.05" << endl;
moe = moe%5;
cout << moe << " moeda(s) de R$ 0.01" << endl;
}
}
Problema 1179
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int n, contp, conti, cont;
int par[5], impar[5];
contp = 0, conti = 0, cont = 0;
while(cin >> n)
{
cont++;
if(n%2 == 0)
{
par[contp] = n;
contp++;
if(contp == 5)
{
for(int i = 0; i < 5; i++)
cout << "par[" << i << "] = " << par[i] << endl;
contp = 0;
}
}
else
{
impar[conti] = n;
conti++;
if(conti == 5)
{
for(int i = 0; i < 5; i++)
cout << "impar[" << i << "] = " << impar[i] << endl;
conti = 0;
}
}
if(cont == 15)
{
for(int i = 0; i < conti ; i++)
cout << "impar[" << i << "] = " << impar[i] << endl;
for(int i = 0; i < contp; i++)
cout << "par[" << i << "] = " << par[i] << endl;
}
}
}
Problema 1187
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
double acc = 0;
double mat[12][12];
char esc;
cin >> esc;
for(int i = 0; i < 12; i++)
for(int j = 0; j < 12; j++)
cin >> mat[i][j];
/*
for(int i = 0; i <= 11; i++)
{
for(int j =0; j <= 11; j++)
cout << mat[i][j] << " ";
cout << endl;
}
*/
for(int i = 0; i <= 11; i++)
for(int j = 0; j <= 11; j++)
if((i+j) < 11 && j > i)
{
acc += mat[i][j];
}
if(esc == 'S')
printf("%.1f\n",acc);
else
printf("%.1f\n",acc/30.0);
}