We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Practice
  2. Algorithms
  3. Implementation
  4. Grading Students
  5. Discussions

Grading Students

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

    You are viewing a single comment's thread. Return to all comments →

  • jorgedaniel29_jg 1 month ago+ 0 comments

    Solution in C:

    int* gradingStudents(int grades_count, int* grades, int* result_count) {
        int *resultGrades = malloc(grades_count * sizeof(int));
        (*result_count) = 0;
        for (int i = 0; i < grades_count; i++) {
    
            int grade = grades[i], rounding = ((grade + 5) - ((grade + 5) % 5));
    
            if (grade >= 38 && grade < 100 && ((rounding - grade) < 3)) {
                resultGrades[i] = rounding;
            } else resultGrades[i] = grade;
    
            (*result_count)++;
    
            printf("%d\n", resultGrades[i]);
        }
        return resultGrades;
    }
    
    1|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature