Header Ads

Header ADS

URI 1040 Average 3 Solution in C++

URI 1040 👀 Average 3  👀Solution in C++

Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comments.

URI 1040 Average 3 Solution in C++

#include <bits/stdc++.h>
using namespace std;
#define SC1(a) scanf("%f", &a)

#define SC4(a, b, c, d) scanf("%f %f %f %f", &a, &b, &c, &d)

int main(int argc, char const *argv[]){
 float a, b, c, d, m, f;

 SC4(a, b, c, d);
 a = (a * 20)/100;
 b = (b * 30)/100;
 c = (c * 40)/100;
 d = (d * 10)/100;
 m = a + b + c + d;

 if(m >= 7.0){
  printf("Media: %.1f\nAluno aprovado.\n", m);
 }else if(m < 5.0){
  printf("Media: %.1f\nAluno reprovado.\n", m);
 }else{
  SC1(f);
  printf("Media: %.1f\nAluno em exame.\nNota do exame: %.1f\n", m, f);
  if ((m + f) / 2 < 5.0) printf("Aluno reprovado.\nMedia final: %.1f\n", (m + f) / 2);
  else printf("Aluno aprovado.\nMedia final: %.1f\n", (m + f) / 2);
 }

 return 0;}


1 comment:

  1. #include
    #include
    using namespace std;

    int main() {
    float n1,n2,n3,n4,ex,avg,avg2;
    cin>>n1>>n2>>n3>>n4;
    cin>>ex;
    n1=n1*2;
    n2=n2*3;
    n3=n3*4;
    n4=n4*1;
    avg=(n1+n2+n3+n4)/(2+3+4+1);
    std::cout<=7.0){
    cout<<"Aluno aprovado."<=5 && avg<=6.9){
    cout<< "Aluno em exame."<=5){
    cout<<"Aluno reprovado."<<endl;
    std::cout<<std::fixed;
    std::cout<<std::setprecision(1);
    std::cout<<"Media final:"<<avg2<<endl;
    }
    else if (avg2<=4.9){
    cout<<"Aluno reprovado."<<endl;
    std::cout<<std::fixed;
    std::cout<<std::setprecision(1);
    std::cout<<"Media final:"<<avg2<<endl;
    }
    return 0;
    }
    what's wrong with my code?

    ReplyDelete

URI 1070 Six Odd Numbers Solution in C++

URI 1070 Six Odd Numbers Solution in C++ Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just fin...

Powered by Blogger.