#Simple Question

38 messages · Page 1 of 1 (latest)

buoyant hornet
#

I've tried for so many times but I still got wrong ans, I don't know why...

small horizonBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@buoyant hornet

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

haughty shuttle
#

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

wintry aspen
#

!f

small horizonBOT
#
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main() {
  float n, k, mark, a;
  a = 0;
  k = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> mark;
    a += mark;
  }
  cout << fixed;
  cout << setprecision(1);
  k = a / n;
  if (mark == 3) {
    cout << "None" << endl;
  }
  if (a == 5 * n && mark == 5) {
    cout << "Named" << endl;
  } else if (k >= 4.5 && mark > 3) {
    cout << "High" << endl;
  } else if (mark > 3 && k < 4.5) {
    cout << "Common" << endl;
  }

  return 0;
}
Steffie
wintry aspen
#

were u having issues ?

buoyant hornet
#

Um, I was new to discord so I don't really understand the features. Can you see my question photos?

haughty shuttle
#

what is fixed?

#

why are you setprecision(i) you need to help us so that we can help lol

buoyant hornet
wintry aspen
#

that its correct setprecision(1) will set precision to 1 decimal

buoyant hornet
buoyant hornet
wintry aspen
#
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;
int main() {
  int n =0;
  float result =0, mark =0, sum =0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> mark;
    sum += mark;
  }
  result = sum / n;

  cout << fixed << setprecision(1);

//fix the if's
  if (result == 3) {
    cout << "None" << endl;
  }
  else if (result == 5 ) {
    cout << "Named" << endl;
  } else if (result >= 4.5 ) {
    cout << "High" << endl;
  } else if (result > 3 ) {
    cout << "Common" << endl;
  }

  return 0;
}```
buoyant hornet
wintry aspen
buoyant hornet
#

Do you mean I should changed the if?

real quarry
#

!f

small horizonBOT
#
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;
int main() {
  int n = 0;
  float result = 0, mark = 0, sum = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> mark;
    sum += mark;
  }
  result = sum / n;

  cout << fixed << setprecision(1);

  if (result == 3) {
    cout << "None" << endl;
  } else if (result == 5) {
    cout << "Named" << endl;
  } else if (result >= 4.5 && mark > 3) {
    cout << "High" << endl;
  } else if (result > 3 && result < 4.5) {
    cout << "Common" << endl;
  }

  return 0;
}
Steffie
real quarry
#

also a small note I reccomend against using #include <bits/stdc++.h>

#

it's non standard and should honestly never be used

haughty shuttle
#

^ x2

#

and using namespace std

haughty shuttle
buoyant hornet
buoyant hornet
earnest pier
#

(Except those internal includes but no one uses them, they're only used by stdlib)

earnest pier
#

Not that I'd ever do it but yk

haughty shuttle
#

yep

#

Name collisions

earnest pier
#

And before anyone points out that C headers are a part of stdlib
while you're right
even the compiler tells you to use the C++ variant instead

#

cmath instead of math.h for example

small horizonBOT
#

@buoyant hornet Has your question been resolved? If so, run !solved :)

buoyant hornet
#

!solved