/ SeriousOJ /

Record Detail

Compile Error

foo.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.

Code

#include <iostream>
#include <cmath>

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void simplifyFraction(int &numerator, int &denominator) {
    int commonDivisor = gcd(numerator, denominator);
    numerator /= commonDivisor;
    denominator /= commonDivisor;
}

int main() {
    int numGames;
    std::cout << "Enter the number of games: ";
    std::cin >> numGames;

    for (int i = 0; i < numGames; ++i) {
        int achievementsAvailable, achievementsUnlocked;
        std::cin >> achievementsAvailable;

        
        std::cin >> achievementsUnlocked;


        int numerator = achievementsUnlocked * 100;
        int denominator = achievementsAvailable;

        simplifyFraction(numerator, denominator);

        std::cout  << ": " << numerator << " / " << denominator << "\n\n";
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1001 Achievement-Unlocked
Language
C99 (GCC 13.2.0)
Submit At
2024-03-06 13:07:49
Judged At
2024-03-06 13:07:49
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes