0
How to output the largest number of a sequence of numbers seperated by commas?
7 Réponses
0
Wait, so you have the numbers stored in a string and not in an array? Otherwise just loop through all of them and look for the highest value (store its position in an additional variable so you can compare it with the other values in the array).
0
I am given the number of students the maximum grades a student can have (each student has a different amount of grades from 1-10)
What I have to do is find the largest and the smallest grade of each student
0
So the grades are stored in an array? Well, then you can just do it as I said. If you have some code already, but it's not working right just share it here so we can figure out the problem.
0
I don't have any code ready , I am just trying to figure out the problem first
0
The point is one student can have 4 grades and one other student has 6 grades.
I am not allowed to type first the number of grades a student has so i can't loop them . My input is only the number of students and the grades themself. I have to write them all separeted by commas for each student. And at the and find the highest and the lowest for each student .
0
Do you need to test for wrong inputs? If not you can use something like this:
do{
cin >> x;
cout << x << endl;
} while (getchar() != '\n'); /* <stdio.h> */
It will give you the separate numbers from an input like "1,2,4,19". Instead of cout you'd probably wan't to store the values in an array or something.
0
Thank you :)