So Im trying to solve the problem here: https://open.kattis.com/problems/acm
Im supposed to give teams a time score based on their results. The input is supposed to be in the form:
"minutes" "uppercase letter" "right/wrong", for instance: 30 B right, written on n number of lines. When there are no more lines, the user will input -1. I tried to use cin.get to end the while loop when this was input, but it did not work.
Also, i made a vector containing uppercase letters in the order they were input, and i wanna do a strcmp with elements in this vector and the uppercase letter that was most recently input, but i get the following error: No matching function for call to 'strcmp'. Candidate function not viable: no known conversion from 'char' to 'const char *' The strcmp where i compare str to "right" however works fine.
Im sorry i didn't specify. The strcmp where i compare str to "right" works just fine, its the second strcmp where i compare c and v[i] which doesen't work.
The strcmp where i compare str to "right" works just fine
I was trying to get you to use a string, not an array of char, and to use C++ facilities not C functions. In other words think in C++, not C - which is a different language.
.... and i wanna do a strcmp with elements in this vector and the uppercase letter that was most recently input ....
Does the time += 20; work properly? Where should the for loop be in the code? Under what circumstances is 20 added to the score?
How do i make sure the while loop stops when user inputs -1 though?
When you read the documentation for std::cin.get , what does it tell you for the way you are calling it? What other much more normal methods do you have for reading a number from the input?
I also tried using while (t !=-1) but that didn't work either. Im not sure what you're referring to with "much more normal methods for reading a number from the input". I tried using scanf instead for what its worth, but the result remained the same.
Every time they get a problem right i wanna check how many times they got the problem wrong previously, so i can add a 20 minute time penalty for each attempt they used at the problem they got right, hence the for loop.
Every time they get a problem right i wanna check how many times they got the problem wrong previously, so i can add a 20 minute time penalty for each attempt they used at the problem they got right, hence the for loop.
But you are doing that every time the while loop goes around, so the time added with the 20 will be huge.
While c.in != -1 ? I've already tried checking if the variable c that I take in equals -1, but that didn't work. I don't know how to use cin any other way to check whether -1 was input by the user.
My intention is that the for loop should only activate if the if(strcmp("right", str) == 0) condition is met. Im only checking for that specific letter they just got right, and i will only check for that letter once.