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
6 changes: 4 additions & 2 deletions C++/h1.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// find the longest pallindrome in the string
// This program is designed to find the longest palindrome in a given string
// ie. if the string given is 'djhfacdadcaop' the longest palindrom is 'acdadca'
// ie. if the string given is 'djhfacdadcaop' the longest palindrom is 'acdadca'
// which should be the return value for the function longest pallindrome(char* s).

#include<iostream>
#include<cstring> //

using namespace std;

void printSubStr(
Expand All @@ -19,7 +21,7 @@ int longestPalSubstr(string str)

bool table[n][n];

memset(table, 0, sizeof(table));
memset(table, 0, sizeof(table)); //

int maxLength = 1;

Expand Down
Binary file added C++/h1.exe
Binary file not shown.
Binary file added C++/h1.o
Binary file not shown.
Binary file added C++/h2.exe
Binary file not shown.
Binary file added C++/h2.o
Binary file not shown.
Binary file added C++/m1.o
Binary file not shown.
2 changes: 1 addition & 1 deletion C++/m3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ main() {
char *myval = initialize();
cin >> *myval;
cout << "Variable intialized" << endl;
do_something_with(myval);
do_something_with(char * myval);
}
Binary file added C++/m3.exe
Binary file not shown.
Binary file added C++/m3.o
Binary file not shown.
2 changes: 1 addition & 1 deletion C++/m6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include<string>

int main(){
std :: string s = "Hello World";
std :: string s = "a . ,";//doesnt work for special characters.

for(int i=0;i < s.length(); i++){
s[i] = toupper(s[i]);
Expand Down
Binary file added C++/m6.exe
Binary file not shown.
Binary file added C++/m6.o
Binary file not shown.
6 changes: 3 additions & 3 deletions C++/s1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using namespace std;

int reverse(int x) {
long r=0;
long r=0;
while(x){
r=r*10+x/10;
x=x/10;
r=r*10+x%10;
x=x/10;
}
return r;
}
Expand Down
Binary file added C++/s1.exe
Binary file not shown.
Binary file added C++/s1.o
Binary file not shown.
Binary file added C++/s2.exe
Binary file not shown.
Binary file added C++/s2.o
Binary file not shown.
2 changes: 1 addition & 1 deletion C++/s3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using namespace std;

int i = 5;
int j;
int j=7;//initialize j(we initialized j as 7)

int foo(int j) {
for (i=0; i<j; i++){
Expand Down
Binary file added C++/s3.exe
Binary file not shown.
Binary file added C++/s3.o
Binary file not shown.
4 changes: 3 additions & 1 deletion C++/s4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ using namespace std;

int random(){
srand(time(0));
return rand();
int t=rand();
return t;
}


int main(void){
int i=6, j=7;

int val = Random(j-i+1);

cout << val << endl;
Expand Down
Binary file added C++/s4.exe
Binary file not shown.
Binary file added C++/s4.o
Binary file not shown.
5 changes: 3 additions & 2 deletions C++/s5.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include<iostream>
#include<string.h>
using namespace std;


int main(void){
string string1 = "Hello";
string string2 = "Horld";

string string2 = "Hello";
if (string1 == string2)
cout << "Equal";

else
cout << "Not Equal";
}
Binary file added C++/s5.exe
Binary file not shown.
Binary file added C++/s5.o
Binary file not shown.
13 changes: 11 additions & 2 deletions C++/s6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ using namespace std;
int maxSubArraySum(int a[], int size)
{
int max_so_far = INT_MIN, max_ending_here;

for (int i = 0; i < size; i++) {
max_ending_here = max_ending_here + a[i];
if (max_so_far < max_ending_here)
max_so_far = max_ending_here;

if (max_ending_here < 0)
max_ending_here = max_so_far;
}
return max_so_far;
}
int main()
{

int arr[]={-1,-2,-3,-3,-8};
cout<<maxSubArraySum(arr,5);

return 0;

}
Binary file added C++/s6.exe
Binary file not shown.
Binary file added C++/s6.o
Binary file not shown.