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
72 changes: 72 additions & 0 deletions lab2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Implement C++ program for finding out the saddle point in a matrix.
#include <iostream>
using namespace std;
class saddle_pt
{
int a[3][3];
public:
void input()
{
cout << "Enter data in Matrix : " << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << "Enter element [" << i << "," << j << "] : ";
cin >> a[i][j];
}
}
}
void display()
{
cout << "\nMatrix : " << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
}
void ifSaddlePoint()
{
bool check;
int ch = 0;
cout << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
check = false;
for (int k = 0; k < 3; k++)
{
if (a[i][j] >= a[k][j] && a[i][j] <= a[i][k])
check = true;
else
{
check = false;
break;
}
}
if (check == true)
{
cout << a[i][j] << " is the Saddle point at position " << i << "," << j << endl
<< endl;
ch++;
}
}
}
if (ch == 0)
cout << "There's no Saddle point in the matrix.\n"
<< endl;
}
};
int main()
{
saddle_pt obj;
obj.input();
obj.display();
obj.ifSaddlePoint();
return 0;
}
57 changes: 57 additions & 0 deletions lab3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Implement C++ program for Random password generation
#include <iostream>
using namespace std;
class R_password
{
public:
void generate()
{
cout << "All possible passwords out of '1, 3, a, s, t and i' are : " << endl;
string str = "13asti", str1 = "13asti";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
for (int k = 0; k < 6; k++)
{
for (int l = 0; l < 6; l++)
{
for (int m = 0; m < 6; m++)
{
for (int n = 0; n < 6; n++)
{
str1[0] = str[i];
str1[1] = str[j];
str1[2] = str[k];
str1[3] = str[l];
str1[4] = str[m];
str1[5] = str[n];
bool check = true;
for (int p = 0; p < 6; p++)
{
for (int q = 0; q < 6; q++)
{
if (p == q)
continue;
if (str1[p] == str1[q])
check = false;
}
}
if (check == true)
{
cout << str1 << " ";
}
}
}
}
}
}
}
}
};
int main()
{
R_password obj;
obj.generate();
return 0;
}