Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
66 changes: 50 additions & 16 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ using namespace std;


/** WRITE DOWN YOUR INFORMATION HERE */
string name = ""; // put your name here
string ID = ""; // put your student id here
int group_id = 0; // your Group Number here (1-8)
/*string name = "HASSAN RIZKY PUTRA SAILELLAH"; // put your name here
string ID = "1301190328"; // put your student id here

string name = "MUHAMMAD IKRAM KAER SINAPOY"; // put your name here
string ID = "1301193341"; // put your student id here

string name = "ARPRIANSAH YONATHAN"; // put your name here
string ID = "1301194112"; // put your student id here

string name = "NAUFAL YOZHA REVANSYAH"; // put your name here
string ID = "1301194282"; // put your student id here

*/

string name = " "; // put your name here
string ID = " "; // put your student id here
int group_id = 1; // your Group Number here (1-8)


/** FUNCTIONS LIST, DO NOT MODIFY THESE */
Expand Down Expand Up @@ -53,11 +67,24 @@ void insert_sort(int arr[], int &n, int x) {
x : number to be inserted
*/

// YOUR CODES HERE
//-----------------------
arr[n] = x;
n = n + 1;

int i, key, j;
for (i = 1; i < n; i++){
key = arr[i];
j = i - 1;
while (j >= 0 && arr[j] > key){
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
}
}




//-----------------------
}


Expand Down Expand Up @@ -147,13 +174,20 @@ string count_and_sum(int arr[], int n) {
arr : input array
n : number of element inside array
*/

// YOUR CODES HERE
//-----------------------


//-----------------------
int i, genap, ganjil;
genap = 0;
ganjil = 0;

for(i = 0; i < n; i++){
if(arr[i]%2 == 0){
genap = genap + arr[i];
} else {
ganjil = ganjil + 1;
}
}
cout << "count odd = " << ganjil << ", sum even = " << genap;
return "";

}


Expand Down Expand Up @@ -198,7 +232,7 @@ void view_data_1(int arr[], int n) {
// YOUR CODES HERE
//-----------------------
for(int i=0; i<n; i++) {
cout<<arr[i]<<" ";
cout<<arr[i]<<", ";
}
cout<<endl;
//-----------------------
Expand Down Expand Up @@ -255,10 +289,10 @@ void check_group(int id) {
cin.get();

view_data_1(arr,n);
string s = count_and_sum(arr,n);

cout<<"expected output: count odd = 1, sum even = 12"<<endl;
cout<<"your output : "<< s;

cout<<"your output : ";
count_and_sum(arr,n);
break;
}
case 2: {
Expand Down
Binary file added main.exe
Binary file not shown.