Skip to content

Commit

Permalink
cpp program
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanmay-Saxena10 committed Oct 16, 2022
1 parent bf37bdf commit 4996794
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 35 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added leetcode/findthedifference.cpp
Empty file.
File renamed without changes.
File renamed without changes.
70 changes: 35 additions & 35 deletions reverseTwopointer.cpp → leetcode/reverseTwopointer.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
// To reverse array of given data using two poiter approach
// Created by Vatsal Jha on 12th October 2022
#include <iostream>
using namespace std;
void reverseArray(int arr[], int n)
{
int s = 0;
int e = n - 1;
while (s <= e)
{
int temp = arr[s];
arr[s] = arr[e];
arr[e] = temp;
s++;
e--;
}
cout << "after reversing" << endl;
for (int i = 0; i < n; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int k = sizeof(arr) / sizeof(int);
cout << "before reversing=" << endl;
for (int i = 0; i < k; i++)
{
cout << arr[i] << " ";
}
cout << endl;
reverseArray(arr, k);
return 0;
// To reverse array of given data using two poiter approach
// Created by Vatsal Jha on 12th October 2022
#include <iostream>
using namespace std;
void reverseArray(int arr[], int n)
{
int s = 0;
int e = n - 1;
while (s <= e)
{
int temp = arr[s];
arr[s] = arr[e];
arr[e] = temp;
s++;
e--;
}
cout << "after reversing" << endl;
for (int i = 0; i < n; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int k = sizeof(arr) / sizeof(int);
cout << "before reversing=" << endl;
for (int i = 0; i < k; i++)
{
cout << arr[i] << " ";
}
cout << endl;
reverseArray(arr, k);
return 0;
}

0 comments on commit 4996794

Please sign in to comment.