-
Notifications
You must be signed in to change notification settings - Fork 0
/
pretest.cpp
43 lines (39 loc) · 829 Bytes
/
pretest.cpp
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
/*
Nama : Shalvina Zahwa Aulia
NPM : 140810180052
Kelas : B
Tanggal : 6 Maret 2019
*/
#include <iostream>
using namespace std;
void moveZeroToFront (int arr[], int n);
void input (int (&arr)[100], int& n);
void output (int arr[], int n);
int main(){
int arr[100];
int n;
input(arr,n);
moveZeroToFront(arr,n);
output(arr,n);
}
void moveZeroToFront(int arr[], int n){
int jumlah =0;
for (int i=1; i<n; i++){
if (arr[i]=0){
arr[i]=arr[jumlah];
jumlah++;
}
}
}
void input (int (&arr)[100],int& n){
cout<< "Masukan batas : "; cin >> n;
for (int i=1; i<=n;i++){
cout << "Masukan input ke-"<<i<< " : ";
cin >> arr [i];
}
}
void output(int arr[], int n){
for (int i=0; i<=n;i++){
cout << arr[i] <<" , ";
}
}