forked from amankayat/HackerRank-Solution-Algorithm-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradesroundof.cpp
More file actions
46 lines (36 loc) · 769 Bytes
/
gradesroundof.cpp
File metadata and controls
46 lines (36 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
/*
* Complete the 'gradingStudents' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts INTEGER_ARRAY grades as parameter.
*/
int *roundoffgrade(int a[100],int n){
static int ar[100];
for(int i=0;i<n;i++){
if(a[i]>37){
if((a[i]%5)==3){
int x= a[i]%5;
a[i]+=(x-1);
}else if((a[i]%5)==4){
a[i]+=1;
}
}
}
for(int i=0;i<n;i++)
ar[i]=a[i];
return ar;
}
int main(){
int n,a[100];
int *result;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
result = roundoffgrade(a,n);
for(int i=0;i<n;i++){
cout<<result[i]<<"\n";
}
}