diff --git a/Aktardb.cpp b/Aktardb.cpp new file mode 100644 index 0000000..ac59c07 --- /dev/null +++ b/Aktardb.cpp @@ -0,0 +1,155 @@ +#include + +using namespace std; + +// CLASS DECLARATION + +class DB +{ + +public: + void store(); + void viewChronologically(); + void sortbyPartID(); + void viewbyPartID(); + +private: + class Part // This "public class" could also be a "struct" instead. + { + public: + int sl; + int ID; + float Price; + int Quantity; + Part(void){}; + Part(int Partnum, float rate, int quant) + { + ID = Partnum; + Price = rate; + Quantity = quant; + } // DO: Initialize appropriately. + + void store(int s) + { + sl = s; + // DO: Fill in prompts and input statements as indicated by the + cout << "Enter ID: "; + cin >> ID; + cout << "Enter Unit Price: "; + cin >> Price; + cout << "Enter Inventory Quantity: "; + cin >> Quantity; + // sample output: + }; + + void print() + { + cout << "Part ID: " << ID << "\tUnit Price = " << Price << "\t\tInventory = " << Quantity << endl; + }; + }; + + Part n1, n2, n3; + + Part *IDp1, *IDp2, *IDp3; + + void swap(Part *a, Part *b); + void sortbyChronologicalOrder(); +}; + +// CLASS DEFINITION +void DB::store() +{ + + cout << "Input ID, price, and quantity for three parts, as prompted" << endl; + + cout << "Part 1:" << endl; + n1.store(1); + + cout << "Part 2:" << endl; + n2.store(2); + + cout << "Part 3:" << endl; + n3.store(3); + + IDp1 = &n1; + IDp2 = &n2; + IDp3 = &n3; + + // DO: Print a thank you message after storing as indicated in the + cout << "Thank you. The three parts have been securely stored in the database." << endl; + + // sample output: +}; + +void DB::viewChronologically() +{ + sortbyChronologicalOrder(); + cout << "The three items in the database (in chronological order) are: " << endl; + + n1.print(); + n2.print(); + n3.print(); +}; + +// DO: Fill in the definition for the swap method in the DB class: + +void DB::swap(DB::Part *a, Part *b) +{ + Part temp; + temp = *a; + *a = *b; + *b = temp; +}; + +void DB::sortbyPartID() +{ + + if (IDp1->ID > IDp2->ID) + swap(IDp1, IDp2); + + if (IDp2->ID > IDp3->ID) + { + swap(IDp2, IDp3); + + if (IDp1->ID > IDp2->ID) + swap(IDp1, IDp2); + } +}; + +void DB::sortbyChronologicalOrder() +{ + if (IDp1->sl > IDp2->sl) + swap(IDp1, IDp2); + + if (IDp2->sl > IDp3->sl) + { + swap(IDp2, IDp3); + + if (IDp1->sl > IDp2->sl) + swap(IDp1, IDp2); + } +} + +void DB::viewbyPartID() +{ + // DO: Fill in based on sample output: + cout << "The three items in the database (sorted by part ID) are:" << endl; + + n1.print(); + n2.print(); + n3.print(); +}; + +int main() +{ + + DB DB1; + DB1.store(); + DB1.sortbyPartID(); + DB1.viewbyPartID(); + DB1.viewChronologically(); + + cout << "Have a good day! Bye!" << endl; + + exit(0); +}; \ No newline at end of file diff --git a/Form.html b/Form.html new file mode 100644 index 0000000..f41836d --- /dev/null +++ b/Form.html @@ -0,0 +1,47 @@ + + + + + + + + HTML FORM + + + + + +
+
+ First Name :
+ Last Name :
+ Contact No :
+ Gender:Male + Female

+ Hubbies :
+
+ +
+ +

+ Country :

+ + +
+
+ + + \ No newline at end of file diff --git a/SamsREFUND.png b/SamsREFUND.png new file mode 100644 index 0000000..d69ed29 Binary files /dev/null and b/SamsREFUND.png differ diff --git a/comp.py.ipynb b/comp.py.ipynb new file mode 100644 index 0000000..9f40bca --- /dev/null +++ b/comp.py.ipynb @@ -0,0 +1,151 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "1\n", + "[1]\n", + "1\n", + "2\n", + "[1, 2]\n", + "5\n", + "4\n", + "[1, 2, 3, 4]\n", + "119\n" + ] + } + ], + "source": [ + "# cook your dish here\n", + "n = int(input())\n", + "for i in range(n):\n", + " x = input()\n", + " x = int(x)\n", + " l = [j for j in range(1,x+1)]\n", + " print(l)\n", + " while len(l) != 1:\n", + " f = l[0]\n", + " la = l[-1]\n", + " l = l[1:-1]\n", + " l.append(f + la + f*la)\n", + " \n", + " print(l[0]%1000000007)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "5\n", + "5\n", + "719\n", + "4\n", + "119\n" + ] + } + ], + "source": [ + "n = int(input())\n", + "l = [1]\n", + "for i in range(1,1000001):\n", + " l.append((l[i-1] * i)% 1000000007)\n", + "for i in range(n):\n", + " x = input()\n", + " x = int(x)\n", + " print(l[x+1]-1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n", + "cabbac\n", + "YES\n" + ] + } + ], + "source": [ + "t = int(input())\n", + "for i in range(t):\n", + " s = input()\n", + " l = [s.count(i)%2 for i in s]\n", + " if 1 in l:\n", + " print('NO')\n", + " else:\n", + " print('YES')" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": "7\n" + } + ], + "source": [ + "n = int(input())\n", + "st = {}\n", + "for i in range(n):\n", + " l = input().split(\" \")\n", + " l = [int(j) for j in l]\n", + " for j in range(l[0],l[1]):\n", + " st[j] = 1\n", + "print(len(st))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.8.3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3-final" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/d1.c b/d1.c new file mode 100644 index 0000000..33c897e --- /dev/null +++ b/d1.c @@ -0,0 +1,104 @@ +#include +#include + +struct NAME +{ + char first_name[20], middle_name[20], last_name[20]; +}; +struct DATE +{ + int dd, mm, yy; +}; +struct student +{ + int roll_no; + struct NAME name; + char course[20]; + struct DATE DOB; + float fees; +} arr[10]; + +void display(int t) +{ + int i; + for (i = 0; i <=t; i++) + { + printf("\nRoll : %d", arr[i].roll_no); + printf("\nFirst Name : %s", arr[i].name.first_name); + printf("\nMiddle Name : %s", arr[i].name.middle_name); + printf("\nLast Name : %s", arr[i].name.last_name); + printf("\nCourse : %s", arr[i].course); + printf("\nDOB date : %d", arr[i].DOB.dd); + printf("\nDOB Month : %d", arr[i].DOB.mm); + printf("\nDOB Year : %d", arr[i].DOB.yy); + printf("\nFees : %f", arr[i].fees); + } +} + +void Insert(int i) +{ + printf("Enter Details of Student : %d\n", i + 1); + printf("Enter roll\n"); + scanf("%d", &arr[i].roll_no); + printf("Enter First name\n"); + scanf("%s", &arr[i].name.first_name); + printf("Enter Middle name\n"); + scanf("%s", &arr[i].name.middle_name); + printf("Enter Last name\n"); + scanf("%s", &arr[i].name.last_name); + printf("Enter Course\n"); + scanf("%s", &arr[i].course); + printf("Enter Date of Birth\n"); + scanf("%d", &arr[i].DOB.dd); + printf("Enter Month of Birth\n"); + scanf("%d", &arr[i].DOB.mm); + printf("Enter Year of Birth\n"); + scanf("%d", &arr[i].DOB.yy); + printf("Enter Total Fees\n"); + scanf("%f", &arr[i].fees); +} + +int main() +{ + int i, t = -1; + printf("Enter \n1 for Insert\n2 for Display\n3 for Delete Last Student\n4 for Exit\n"); + int op, bool = 1; + while (bool) + { + printf("Enter Option\n"); + scanf("%d", &op); + switch (op) + { + case 1: + if (t < 9) + { + t++; + Insert(t); + } + else + { + printf("Already 10 Student present"); + } + break; + case 2: + display(t); + break; + case 3: + if (t < 0) + { + printf("No Student to delete"); + } + else + { + printf("%d Roll No deleted\n", arr[t].roll_no); + t--; + } + break; + case 4: + bool = 0; + break; + } + } + + return 0; +} \ No newline at end of file diff --git a/d2.c b/d2.c new file mode 100644 index 0000000..ad3035d --- /dev/null +++ b/d2.c @@ -0,0 +1,99 @@ +#include +#include + +struct NAME +{ + char first_name[20], middle_name[20], last_name[20]; +}; +struct DATE +{ + int dd, mm, yy; +}; +struct student +{ + int roll_no; + struct NAME name; + char course[20]; + struct DATE DOB; + float fees; +} arr[10]; + +// Question No 2 +void sort(int t) +{ + struct student *pstud, temp; + int i; + pstud = &arr[0]; + for (i = 0; i < t; i++) + { + for (pstud = &arr[0]; pstud < &arr[t - i - 1]; pstud++) + { + printf("\n%s\n", pstud->name.first_name); + if (pstud->DOB.yy > (pstud + 1)->DOB.yy) + { + temp = *pstud; + *pstud = *(pstud + 1); + *(pstud + 1) = temp; + } + } + } +} + +int main() +{ + int i, t; + t = 10; + printf("Enter Details of 10 Students\n"); + for (i = 0; i < t; i++) + { + printf("Enter Details of Student : %d\n", i + 1); + printf("Enter roll\n"); + scanf("%d", &arr[i].roll_no); + printf("Enter First name\n"); + scanf("%s", &arr[i].name.first_name); + printf("Enter Middle name\n"); + scanf("%s", &arr[i].name.middle_name); + printf("Enter Last name\n"); + scanf("%s", &arr[i].name.last_name); + printf("Enter Course\n"); + scanf("%s", &arr[i].course); + printf("Enter Date of Birth\n"); + scanf("%d", &arr[i].DOB.dd); + printf("Enter Month of Birth\n"); + scanf("%d", &arr[i].DOB.mm); + printf("Enter Year of Birth\n"); + scanf("%d", &arr[i].DOB.yy); + printf("Enter Total Fees\n"); + scanf("%f", &arr[i].fees); + } + + for (i = 0; i < t; i++) + { + printf("\nRoll : %d", arr[i].roll_no); + printf("\nFirst Name : %s", arr[i].name.first_name); + printf("\nMiddle Name : %s", arr[i].name.middle_name); + printf("\nLast Name : %s", arr[i].name.last_name); + printf("\nCourse : %s", arr[i].course); + printf("\nDOB date : %d", arr[i].DOB.dd); + printf("\nDOB Month : %d", arr[i].DOB.mm); + printf("\nDOB Year : %d", arr[i].DOB.yy); + printf("\nFees : %f", arr[i].fees); + } + + printf("After Sorting "); + sort(t); + for (i = 0; i < t; i++) + { + printf("\nRoll : %d", arr[i].roll_no); + printf("\nFirst Name : %s", arr[i].name.first_name); + printf("\nMiddle Name : %s", arr[i].name.middle_name); + printf("\nLast Name : %s", arr[i].name.last_name); + printf("\nCourse : %s", arr[i].course); + printf("\nDOB date : %d", arr[i].DOB.dd); + printf("\nDOB Month : %d", arr[i].DOB.mm); + printf("\nDOB Year : %d", arr[i].DOB.yy); + printf("\nFees : %f", arr[i].fees); + } + + return 0; +} \ No newline at end of file diff --git a/d3.c b/d3.c new file mode 100644 index 0000000..ef365b5 --- /dev/null +++ b/d3.c @@ -0,0 +1,46 @@ +#include +#include + +union number { + int x1, x2, x3, x4, x5; +}; + +int main() +{ + union number fiveNumbers; + int lowest = INT_MAX; + printf("Enter First Number\n"); + scanf("%d", &fiveNumbers.x1); + if (fiveNumbers.x1 < lowest) + { + lowest = fiveNumbers.x1; + } + printf("Enter Second Number\n"); + scanf("%d", &fiveNumbers.x2); + if (fiveNumbers.x2 < lowest) + { + lowest = fiveNumbers.x2; + } + printf("Enter Third Number\n"); + scanf("%d", &fiveNumbers.x3); + if (fiveNumbers.x3 < lowest) + { + lowest = fiveNumbers.x3; + } + printf("Enter fourth Number\n"); + scanf("%d", &fiveNumbers.x4); + if (fiveNumbers.x4 < lowest) + { + lowest = fiveNumbers.x4; + } + printf("Enter fifth Number\n"); + scanf("%d", &fiveNumbers.x5); + if (fiveNumbers.x5 < lowest) + { + lowest = fiveNumbers.x5; + } + + // printf("\n%d %d %d %d %d\n",fiveNumbers.x1,fiveNumbers.x2,fiveNumbers.x3,fiveNumbers.x4,fiveNumbers.x5); + + printf("Lowest Number Was %d\n", lowest); +} \ No newline at end of file diff --git a/finaltask.cpp b/finaltask.cpp index 4af06d1..0752439 100644 --- a/finaltask.cpp +++ b/finaltask.cpp @@ -9,6 +9,7 @@ int gcd(int a, int b) } + int main() { int N, i, max=1, res=0; diff --git a/hjg.c b/hjg.c new file mode 100644 index 0000000..929a7ee --- /dev/null +++ b/hjg.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +int main() +{ + + int n; + scanf("%d", &n); + int s = 2 * n - 1; + int ss = s; + int a[s][s]; + int p = 0; + while (n > 0) + { + for (size_t i = p; i < s; i++) + { + for (size_t j = p; j < s; j++) + { + if (i == p || j == p || i == s - 1 || j == s - 1) + { + a[i][j] = n; + } + } + } + n--; + s--; + p++; + } + for (size_t i = 0; i < ss; i++) + { + for (size_t j = 0; j < ss; j++) + { + // cout << a[i][j] << " "; + printf("%d ",a[i][j]); + } + printf("\n"); + // cout << endl; + } + + return 0; +} \ No newline at end of file diff --git a/inputUnknownlist.cpp b/inputUnknownlist.cpp new file mode 100644 index 0000000..b653eaa --- /dev/null +++ b/inputUnknownlist.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ + vector v; + + int x; + + while (cin >> x) + + { + v.push_back(x); + } + cout<<"Input Array : "< + +using namespace std; + +// function to reverse bits of a number +unsigned int reverseBits(unsigned int n) +{ + unsigned int rev = 0; + + // traversing bits of 'n' from the right + while (n > 0) + { + // bitwise left shift + // 'rev' by 1 + rev <<= 1; + + // if current bit is '1' + if (n & 1 == 1) + rev ^= 1; + + n >>= 1; + + } + + return rev; +} + +int main() +{ + + unsigned int n ; + cin>>n; + cout << reverseBits(n); + return 0; +} diff --git a/pattern.c b/pattern.c new file mode 100644 index 0000000..5c50303 --- /dev/null +++ b/pattern.c @@ -0,0 +1,58 @@ +#include +#include +#include +int lexicographic_sort(const char* a, const char* b) { + +} + +int lexicographic_sort_reverse(const char* a, const char* b) { + +} + +int sort_by_number_of_distinct_characters(const char* a, const char* b) { + +} + +int sort_by_length(const char* a, const char* b) { + +} + +void string_sort(char** arr,const int len,int (*cmp_func)(const char* a, const char* b)){ + // cmp_func(arr,b); +} + + +int main() +{ + int n; + scanf("%d", &n); + + char** arr; + arr = (char**)malloc(n * sizeof(char*)); + + for(int i = 0; i < n; i++){ + *(arr + i) = malloc(1024 * sizeof(char)); + scanf("%s", *(arr + i)); + *(arr + i) = realloc(*(arr + i), strlen(*(arr + i)) + 1); + } + + string_sort(arr, n, lexicographic_sort); + for(int i = 0; i < n; i++) + printf("%s\n", arr[i]); + printf("\n"); + + string_sort(arr, n, lexicographic_sort_reverse); + for(int i = 0; i < n; i++) + printf("%s\n", arr[i]); + printf("\n"); + + string_sort(arr, n, sort_by_length); + for(int i = 0; i < n; i++) + printf("%s\n", arr[i]); + printf("\n"); + + string_sort(arr, n, sort_by_number_of_distinct_characters); + for(int i = 0; i < n; i++) + printf("%s\n", arr[i]); + printf("\n"); +} \ No newline at end of file diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..7d68a53 --- /dev/null +++ b/test.cpp @@ -0,0 +1,58 @@ +#include +using namespace std; + +class Solution +{ +public: + vector diffWaysToCompute(string input) + { + vector ans; + bool flag = true; + int size = input.length(); + for (size_t i = 0; i < size; i++) + { + char ch = input[i]; + if (ch == '+' || ch == '-' || ch == '*') + { + flag = false; + vector ans_left = diffWaysToCompute(input.substr(0, i)); + vector ans_right = diffWaysToCompute(input.substr(i + 1)); + + for (int n = 0; n < ans_left.size(); n++) + { + for (int m = 0; m < ans_right.size(); m++) + { + switch (ch) + { + case '+': + ans.push_back(ans_left[n] + ans_right[m]); + break; + case '-': + ans.push_back(ans_left[n] - ans_right[m]); + break; + case '*': + ans.push_back(ans_left[n] * ans_right[m]); + break; + } + } + } + } + } + if (flag) + { + ans.push_back(stoi(input)); + cout<<"Conveted "< a = sl.diffWaysToCompute("2*3-4*5"); + for(int v:a){ + cout<