Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.cpp #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
50 changes: 30 additions & 20 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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 = "Akshay Jain"; // put your name here
string ID = "BE/10501/17"; // put your student id here
int group_id = 6; // your Group Number here (1-8)


/** FUNCTIONS LIST, DO NOT MODIFY THESE */
Expand Down Expand Up @@ -68,12 +68,20 @@ void insert_last_unique(int arr[], int &n, int x) {
n : number of element inside array, n should increment by 1 after this procedure executed
x : number to be inserted
*/

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


//-----------------------

bool isUnique = true;

for(int i = 0; i < n; i++) {
if(arr[i] == x) {
isUnique = false;
}
}

if(isUnique == true) {
n++;
arr[n-1] = x;
}

}


Expand Down Expand Up @@ -179,12 +187,15 @@ void swap_data(int arr[], int n) {
arr : input array
n : number of element inside array
*/

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


//-----------------------

int temp; // temporary variable used for performing swap operation

for(int i = 0; i < n/2; i++) {
temp = arr[i];
arr[i] = arr[n-i-1];
arr[n-i-1] = temp;
}

}


Expand Down Expand Up @@ -212,11 +223,10 @@ void view_data_2(int arr[], int n) {
n : number of element inside array
*/

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


//-----------------------
for(int i = 0; i < n; i++) {
cout<<arr[n-i-1]<<" ";
}
cout<<"\n";
}


Expand Down