Loading

C++学习 第一章 变量、输入输出、表达式与顺序语句

第一章 变量、输入输出、表达式与顺序语句

P001 A+B

#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    cout << a + b << endl;

    return 0;
}

P608 做差

#include<iostream>
using namespace std;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << "DIFERENCA = " << (A * B - C * D) << endl;
    
    return 0;
}

P604 圆的面积

#include<iostream>
using namespace std;

int main(){
    
    double pi = 3.14159;
    double r;
    scanf("%lf",&r);
    printf("A=%.4lf",pi*r*r);
    
    
    return 0;
}

P606 平均数

#include<iostream>
using namespace std;

int main(){
    
    double a, b;
    scanf("%lf%lf", &a, &b);
    printf("MEDIA = %.5lf\n",(a * 3.5 + b * 7.5) / 11);
    
    return 0;
    
}

P609 工资

#include<iostream>
using namespace std;
int main()
{
    double wage;
    int code,h;
    cin>>code>>h>>wage;
    printf("NUMBER = %d\n",code);
    printf("SALARY = U$ %.2lf",h*wage);
    return 0;
}

P615 油耗

#include<iostream>

using namespace std;

int main(){
    
    double x, y;
    scanf("%lf%lf", &x, &y);
    printf("%.3lf km/l", x / y);
    
    return 0;
    
}

P616 两点间距离

#include<iostream>
#include<math.h>

using namespace std;

int main(){
    
    
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.4lf",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    
    return 0;
}

P654 时间转化

#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);
    printf("%d:%d:%d", n / 3600, n % 3600 / 60, n % 60);

    return 0;
}

P605 简单乘机

#include<iostream>

using namespace std;

int main(){
    
    int a,b;
    cin >> a >> b;
    cout << "PROD = " << a*b << endl;
    return 0;
    
}

P611 简单计算

#include<iostream>
using namespace std;
int main()
{
    int code,n;
    double price,sum=0.0;
    for(int i=1;i<=2;i++)
        cin>>code>>n>>price,sum+=n*price;
    printf("VALOR A PAGAR: R$ %.2lf",sum);
    return 0;
}

P653 钞票

#include <iostream>

using namespace std;

int main()
{
    int n, a[7] = {100, 50, 20, 10, 5, 2, 1};
    cin >> n;
    printf("%d\n", n);
    for (int i = 0; i < 7; i ++ )
    {
        printf("%d nota(s) de R$ %d,00\n", n / a[i], a[i]);
        n %= a[i];
    }
    return 0;
}

P612 球的体积

#include<cstdio>

int main(){
    
    
    double r;
    scanf("%lf", &r);

    printf("VOLUME = %.3lf\n", 4.0 / 3 * 3.14159 * r * r * r);
    
    return 0;
}

P613 面积

#include <cstdio>

int main()
{
    double a, b, c;
    scanf("%lf%lf%lf", &a, &b, &c);

    printf("TRIANGULO: %.3lf\n", a * c / 2);
    printf("CIRCULO: %.3lf\n", 3.14159 * c * c);
    printf("TRAPEZIO: %.3lf\n", (a + b) * c / 2);
    printf("QUADRADO: %.3lf\n", b * b);
    printf("RETANGULO: %.3lf\n", a * b);

    return 0;
}

P610工资和奖金

#include<cstdio>
#include<iostream>

using namespace std;


int main(){
    
    string name;
    cin >> name;
    
    double x, y;
    cin >> x >> y;
    
    printf("TOTAL = R$ %.2lf\n", x+y*0.15);
    
    
    return 0;
}

P614 最大值

#include<iostream>


using namespace std;


int main(){
    
    
    int a,b,c;
    cin >> a>>b>>c;
    int t = (a + b + abs(a - b)) / 2;
    int r = (t + c + abs(t - c)) / 2;
    cout << r << " eh o maior" << endl;
    
    return 0;
}

P617 距离

#include<iostream>

using namespace std;


int main(){
    
    int l;
    cin >> l;
    cout << 2 * l << " minutos" << endl;
    
    return 0;
}

P618. 燃料消耗

#include<cstdio>

int main(){
    
    
    double x,y;
    scanf("%lf%lf",&x,&y);
    printf("%.3lf\n", x * y / 12);
}

P656. 钞票和硬币

#include <cstdio>

int main()
{
    double m;
    scanf("%lf", &m);
    int n = m * 100;

    printf("NOTAS:\n");
    printf("%d nota(s) de R$ 100.00\n", n / 10000); n %= 10000;
    printf("%d nota(s) de R$ 50.00\n", n / 5000); n %= 5000;
    printf("%d nota(s) de R$ 20.00\n", n / 2000); n %= 2000;
    printf("%d nota(s) de R$ 10.00\n", n / 1000); n %= 1000;
    printf("%d nota(s) de R$ 5.00\n", n / 500); n %= 500;
    printf("%d nota(s) de R$ 2.00\n", n / 200); n %= 200;

    printf("MOEDAS:\n");
    printf("%d moeda(s) de R$ 1.00\n", n / 100); n %= 100;
    printf("%d moeda(s) de R$ 0.50\n", n / 50); n %= 50;
    printf("%d moeda(s) de R$ 0.25\n", n / 25); n %= 25;
    printf("%d moeda(s) de R$ 0.10\n", n / 10); n %= 10;
    printf("%d moeda(s) de R$ 0.05\n", n / 5); n %= 5;
    printf("%d moeda(s) de R$ 0.01\n", n / 1); n %= 1;

    return 0;
}


P655 天数转换

#include<iostream>

using namespace std;


int main(){
    int n;
    cin >> n;
    cout << n/365 << " ano(s)" << endl;
    cout << n % 365 / 30 << " mes(es)" << endl;
    cout << n % 365 % 30 << " dia(s)" << endl;
    
    
    return 0;
}
posted @ 2020-10-01 12:11  想用包子换论文  阅读(493)  评论(0)    收藏  举报