Skip to content

Instantly share code, notes, and snippets.

@feynon
Created November 5, 2018 10:56
Show Gist options
  • Save feynon/b8c78ceb1685479d20640a9b2e7992a7 to your computer and use it in GitHub Desktop.
Save feynon/b8c78ceb1685479d20640a9b2e7992a7 to your computer and use it in GitHub Desktop.
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
using namespace std;
int gradingStudents(int n,int a[]){
int temp;
for(int i=0;i < n;i++){
if(a[i]>38 && a[i] % 5 != 0){
temp = a[i];
do{
temp++;
}
while(temp % 5== 0);
if(temp - a[i] < 3){
a[i] = temp;
}
}
else{
temp = a[i];
}
}
return temp;
}
int main(){
int n;
scanf("%d",& n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",& a[i]);
}
printf("%n",gradingStudents(n,a)); //Only name of an array is passed as an argument
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment