由苟弱cht所做(刚看到有个算法组的所以写了个语法组的)
题目列表:
1, 2, 3, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 726, 727, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779
1. A + B
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b;
}
2.01背包问题
#include<iostream>
using namespace std;
const int N = 1010;
int n,m,v[N],w[N],f[N];
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++ ) cin >> v[i] >> w[i];
for (int i = 1; i <= n; i ++ )
for (int j = m; j >= v[i]; j -- )
f[j] = max(f[j], f[j - v[i]] + w[i]);
cout << f[m];
}
3.完全背包问题
#include<iostream>
using namespace std;
const int N = 1010;
int n,m,v[N],w[N],f[N];
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++ ) cin >> v[i] >> w[i];
for (int i = 1; i <= n; i ++ )
for (int j = v[i]; j <= m; j ++ )
f[j] = max(f[j], f[j - v[i]] + w[i]);
cout << f[m];
}
604.圆的面积
#include<iostream>
using namespace std;
int main()
{
double a;
cin >> a;
printf("A=%.4lf",r*r*3.14159);
}
605.简单乘积
#include<iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
printf("PROD = %d",a*b);
}
606.平均数1
#include<iostream>
using namespace std;
int main()
{
double a, b;
cin >> a >> b;
printf("MEDIA = %.5lf", (a * 3.5 + b * 7.5) / 11);
}
607.平均数2
#include<iostream>
using namespace std;
int main()
{
double a, b, c;
cin >> a >> b >> c;
printf("MEDIA = %.1lf", (a * 2 + b * 3 + c * 5) / 10);
}
608.差
#include<iostream>
using namespace std;
int main()
{
int a, b, c, d;
cin >> a >> b >> c >> d;
printf("DIFERENCA = %d", a * b - c * d);
}
609.工资
#include<iostream>
using namespace std;
int main()
{
int a,b
double x;
cin >> a >> b >> x;
printf("NUMBER = %d\n", a);
printf("SALARY = U$ %.2f", b * c);
}
610.工资和奖金
#include<iostream>
using namespace std;
int main()
{
string a;
double b, c;
cin >> a >> b >> c;
printf("TOTAL = R$ %.2f", a, b + c * 0.15);
}
611.简单计算
#include<iostream>
using namespace std;
int main()
{
int a1, b1, a2, b2;
double c1, c2;
cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
printf("VALOR A PAGAR: R$ %.2lf", b1 * c1 + b2 * c2);
}
612.球的体积
#include<iostream>
using namespace std;
int main()
{
double a;
cin >> a;
printf("VOLUME = %.3lf\n", 4 / 3.0 * 3.14159 * a * a * a);
}
613.面积
#include<iostream>
using namespace std;
int main()
{
double a, b, c;
cin >> a >> b >> c;
printf("TRIANGULO: %.3lf\nCIRCULO: %.3lf\nTRAPEZIO: %.3lf\nQUADRADO: %.3lf\nRETANGULO: %.3lf", a * c / 2,3.14159 * c * c, (a + b) * c / 2, b * b, a * b);
}
614.最大值
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a,a + 3);
cout << a[2]<<" eh o maior";
}
615.油耗
#include <iostream>
using namespace std;
int main()
{
int s;
double o;
cin >> s >> o;
printf("%.3lf km/l", s / o);
}
616.两点间的距离
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
double x = x1 - x2,y = y1 - y2;
printf("%.4lf", sqrt(dx * dx + dy * dy));
}
617.距离
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
printf("%d minutos", a * 2);
}
618.燃料油耗
#include <iostream>
using namespace std;
int main()
{
double a, b;
cin >> a >> b;
printf("%.3lf", a * b / 12);
}
653.钞票
#include <iostream>
using namespace std;
int main()
{
int n, a[7] = {100, 50, 20, 10, 5, 2, 1};
cin >> n;
cout << n << endl;
for (int i = 0; i < 7; i ++ )
{
printf("%d nota(s) de R$ %d,00\n", n / a[i], a[i]);
n %= a[i];
}
}
654.时间转换
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
printf("%d:%d:%d", n / 3600, n % 3600 / 60, n % 60);
}
655.天数转换
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
printf("%d ano(s)\n%d mes(es)\n%d dia(s)", n / 365, n % 365 / 30, n % 365 % 30);
}
656.钞票与硬币(这个是我最不希望碰到的题)
#include <iostream>
using namespace std;
int main()
{
double m;
cin >> m;
int n = m * 100,a[] = {100, 50, 20, 10, 5, 2},b[] = {100, 50, 25, 10, 5, 1};
puts("NOTAS:");
for (int i = 0; i < 6; i ++ )
{
printf("%d nota(s) de R$ %.2lf\n", n / (a[i] * 100), (double)a[i]);
n %= a[i] * 100;
}
puts("MOEDAS:");
for (int i = 0; i < 6; i ++ )
{
printf("%d moeda(s) de R$ %.2lf\n", n / b[i], b[i] / 100.0);
n %= b[i];
}
}
657.选择练习1(记住范围!!!,别写错!!!!)
#include <iostream>
using namespace std;
int main()
{
int a, b, c, d;
cin >> a >> b >> c >> d;
if (b > c && d > a && c + d > a + b && c > 0 && d > 0 && a % 2 == 0) cout << "Valores aceitos";
else cout << "Valores nao aceitos";
}
658.一元二次方程公式
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a, b, c;
cin >> a >> b >> c;
double d = b * b - 4 * a * c;
if (d < 0 || a == 0) cout << "Impossivel calcular" << endl;
else
{
double x = (-b + sqrt(d)) / a / 2;
double y = (-b - sqrt(d)) / a / 2;
printf("R1 = %.5lf\n", x);
printf("R2 = %.5lf\n", y);
}
}
659.区间(水题+难写)
#include <iostream>
using namespace std;
int main()
{
double x;
cin >> x;
if (x >= 0)
if (x <= 25) puts("Intervalo [0,25]");
else if (x <= 50) puts("Intervalo (25,50]");
else if (x <= 75) puts("Intervalo (50,75]");
else if (x <= 100) puts("Intervalo (75,100]");
else puts("Fora de intervalo");
else puts("Fora de intervalo");
}
660.零食(记住,遇到这种题不是啥好事)
#include <iostream>
using namespace std;
int main()
{
int x, y;
cin >> x >> y;
if (x == 1) printf("Total: R$ %.2lf", y * 4.0);
else if (x == 2) printf("Total: R$ %.2lf", y * 4.5);
else if (x == 3) printf("Total: R$ %.2lf", y * 5.0);
else if (x == 4) printf("Total: R$ %.2lf", y * 2.0);
else printf("Total: R$ %.2lf", y * 1.5);
}
661.平均数3(此题超烦)
#include <iostream>
using namespace std;
int main()
{
double a, b, c, d;
cin >> a >> b>> c >> d;
double x = (a * 2 + b * 3 + c * 4 + d * 1) / 10;
printf("Media: %.1lf\n", x);
if (x >= 7) puts("Aluno aprovado.");
else if (x < 5) puts("Aluno reprovado.");
else
{
puts("Aluno em exame.");
double y;
cin >> y;
printf("Nota do exame: %.1lf\n", y);
double z = (x + y) / 2;
if (z >= 5) puts("Aluno aprovado.");
else puts("Aluno reprovado.");
printf("Media final: %.1lf", z);
}
}
沙发!第一!奥利给!
hh
谢谢~