Ad
Code
Diff
  • #include<iostream>
    
    int doubleValue(int x) {
        return x * 2;
    }
    
    • #include<iostream>
    • int doubleValue(int x) {
    • return x * 2;
    • }
    • int main(){
    • int x = 5; //example value
    • int result = doubleValue(x);
    • std::cout << "The double of " << x << " is " << result << std::endl;
    • return 0;
    • }
class Triangle {
public:
  static int otherAngle(int a, int b)
  {
    return (180 - (a + b));
  }
};
Roua99Failed Tests

double value

#include<iostream>

int doubleValue(int x) {
    return x * 2;
}

int main(){
    int x = 5; //example value
    int result = doubleValue(x);
    std::cout << "The double of " << x << " is " << result << std::endl;
    return 0;
}
Roua99Failed Tests

leaderboard

It prints out the leaderboard by iterating through the sorted vector and printing out each student's name and score.

#include <iostream>
#include <vector>
#include <algorithm>

struct Student {
    std::string name;
    int score;
};

bool compare(const Student &a, const Student &b) {
    return a.score > b.score;
}

int main() {
    std::vector<Student> students;

    // Add some students to the vector
    students.push_back({"Alex", 90});
    students.push_back({"max", 70});
    students.push_back({"Charlie", 85});
    students.push_back({"David", 78});
    students.push_back({"Eve", 94});

    // Sort the students by score
    std::sort(students.begin(), students.end(), compare);

    // Print the leaderboard
    std::cout << "Leaderboard:" << std::endl;
    for (const auto &student : students) {
        std::cout << student.name << ": " << student.score << std::endl;
    }

    return 0;
}