diff --git a/lab2.cpp b/lab2.cpp new file mode 100644 index 0000000..3551b9f --- /dev/null +++ b/lab2.cpp @@ -0,0 +1,72 @@ +// Implement C++ program for finding out the saddle point in a matrix. +#include +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; +} \ No newline at end of file diff --git a/lab3.cpp b/lab3.cpp new file mode 100644 index 0000000..7826d5d --- /dev/null +++ b/lab3.cpp @@ -0,0 +1,57 @@ +// Implement C++ program for Random password generation +#include +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; +} \ No newline at end of file