Advertisement
ahamed210

project

Dec 15th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 31.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <windows.h>
  6. #define stack_max 10
  7.  
  8. //char user_id[10];
  9. //char password[10];
  10.  
  11. typedef struct node Node;
  12. struct node{
  13.     int data;
  14.     Node *next;
  15. };
  16.  
  17. struct find_job_detail{
  18.     char f_name[20];
  19.     char l_name[20];
  20.     char email_address[30];
  21.     char phone[13];
  22.     char institute[30];
  23.     double cgpa;
  24.     char job_field[20];
  25.     char exparience[50];
  26. };
  27.  
  28. struct Registration{
  29.     char first_name[20];
  30.     char last_name[20];
  31.     char email[50];
  32.     char user_id[20];
  33.     char password[20];
  34.     char confirm_pass[20];
  35. };
  36.  
  37. void find_job()
  38. {
  39.     system("CLS");
  40.     printf("\n\n\n");
  41.     printf("\t\t\tThanks for chosing us!!!\n\t\t-------------------------------\n");
  42.     printf("We hope, you have the enough qualifications for finding a job here. please send us your informations about you, your qualifications and your chossen field. we\n will contact with you.GOOD LUCK!\n");
  43.     FILE *fp;
  44.     struct find_job_detail i;
  45.     fp = fopen("cv.txt", "w");
  46.     if(fp == NULL){
  47.         perror("File opening failed!");
  48.         return;
  49.     }
  50.     printf("\nEnter Your first Name              : ");
  51.     scanf(" %[^\n]", &i.f_name);
  52.     fprintf(fp, "%s\n", i.f_name);
  53.  
  54.     printf("Enter Your last Name               : ");
  55.     scanf(" %[^\n]", &i.l_name);
  56.     fprintf(fp, "%s\n", i.l_name);
  57.  
  58.     printf("Enter Your Email                   : ");
  59.     scanf(" %[^\n]", &i.email_address);
  60.     fprintf(fp, "%s\n", i.email_address);
  61.  
  62.     printf("Enter Your Phone Number            : ");
  63.     scanf(" %[^\n]", &i.phone);
  64.     fprintf(fp, "%s\n", i.phone);
  65.  
  66.     printf("Enter Your Educational Institue    : ");
  67.     scanf(" %[^\n]", &i.institute);
  68.     fprintf(fp, "%s\n", i.institute);
  69.  
  70.     printf("Enter CGPA                         : ");
  71.     scanf("%lf", &i.cgpa);
  72.     fprintf(fp, "%lf\n", i.cgpa);
  73.  
  74.     printf("Enter Your Job Field               : ");
  75.     scanf(" %[^\n]", &i.job_field);
  76.     fprintf(fp, "%s\n", i.job_field);
  77.  
  78.     printf("Enter Your Work Expariecne         : ");
  79.     scanf(" %[^\n]", &i.exparience);
  80.     fprintf(fp, "%s\n", i.exparience);
  81.  
  82.     printf("\nYour Information has been saved in database wait till our response\n");
  83. }
  84.  
  85. COORD coord = {0,0}; /// top-left corner of window
  86.  
  87. /**
  88.     function : gotoxy
  89.     @param input: x and y coordinates
  90.     @param output: moves the cursor in specified position of console
  91. */
  92. void gotoxy(int x,int y)
  93. {
  94.     coord.X = x;
  95.     coord.Y = y;
  96.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
  97. }
  98.  
  99. void append(Node *head)
  100. {
  101.     Node *temp;
  102.     Node *new_node = (Node *)malloc(sizeof(Node));
  103.     printf("\nEnter Node item for last : ");
  104.     scanf("%d", &new_node->data);
  105.     new_node->next = NULL;
  106.  
  107.     temp = head;
  108.     while(temp->next != NULL)
  109.     {
  110.         temp = temp->next;
  111.     }
  112.     temp->next = new_node;
  113. }
  114.  
  115.  
  116. Node *prepend(Node *head)
  117. {
  118.     Node *new_node = (Node *)malloc(sizeof(Node));
  119.     printf("\nEnter Node item for beganing : ");
  120.     scanf("%d", &new_node->data);
  121.  
  122.     new_node->next = head;
  123.     head = new_node;
  124.  
  125.     return head;
  126. }
  127.  
  128. void add_node(Node *head)
  129. {
  130.     int position, count=0, i=1;
  131.     printf("enter the position after that place new node will be inserted : ");
  132.     scanf("%d", &position);
  133.     Node *temp = head;
  134.  
  135.     while(temp != NULL)
  136.     {
  137.         count++;
  138.         temp = temp->next;
  139.     }
  140.  
  141.     if(position < 1 || position > count+1) printf("Invalid selection!!!\n");
  142.  
  143.     else
  144.     {
  145.         temp = head;
  146.         while(i < position)
  147.         {
  148.             temp = temp->next;
  149.             i++;
  150.         }
  151.         Node *new_node = (Node *)malloc(sizeof(Node));
  152.         printf("\nEnter Node item for the perticular position : ");
  153.         scanf("%d", &new_node->data);
  154.         if(temp == head) {
  155.             new_node->next = head;
  156.             head = new_node;
  157.         }
  158.         else{
  159.         new_node->next = temp->next;
  160.         temp->next=new_node;
  161.         }
  162.     }
  163. }
  164.  
  165. Node *remove_node(Node *head, int total_node)
  166. {
  167.     Node *temp = head;
  168.     if(total_node == 1)
  169.     {
  170.         free(temp);
  171.         return NULL;
  172.     }
  173.  
  174.     int position;
  175.     printf("\n\nEnter the position : ");
  176.     scanf("%d", &position);
  177.  
  178.     if(position == 1)
  179.     {
  180.         head = temp->next;
  181.         free(temp);
  182.         return head;
  183.     }
  184.  
  185.     int i = 1;
  186.     Node *previous_node;
  187.     while(i<position)
  188.     {
  189.         previous_node = temp;
  190.         temp = temp->next;
  191.         i++;
  192.     }
  193.     previous_node->next = temp->next;
  194.     free(temp);
  195.     return head;
  196. }
  197.  
  198. void print_linked_list(Node *head)
  199. {
  200.     Node *temp = head;
  201.     if(head == NULL) return 0;
  202.     while(temp != NULL){
  203.         printf("%d ", temp->data);
  204.         temp = temp->next;
  205.     }
  206.     printf("\n");
  207. }
  208.  
  209. void virtual_judge()
  210. {
  211.     printf("\nThe idea is very simple. As we are doing it by c programming, we will use file to understand the basic working process of virtual judge.\n");
  212.     printf("\nThere will be three(3) file, suppose the name of three file is\n1. input.txt where sample input will be given.");
  213.     printf("\n2. expected_output.txt where sample output will be stored for sameple inputs\n3. output.txt, here output will be stored for the submitted code by learner\n");
  214.     printf("\nAfter this three process, we need to compare expected_output.txt and output.txt these two file. If they are same the code will be accepted.\n");
  215.     printf("\nNow try to implement this idea, for better undersing you can visit to this link\n");
  216.     printf("\nhttps://pastebin.com/qByXFRP5 and \nhttps://pastebin.com/DiCPZfEY\n");
  217.     printf("\nFrom these link you will find a protype problem and implementation virtual judge for this perticular problem.\n");
  218. }
  219.  
  220. void queue()
  221. {
  222.     printf("\n-> enqueue() - add (store) an item to the queue.\n");
  223.     printf("\n-> dequeue()- remove (access) an item from the queue.\n");
  224.     printf("\n-> peek() - Gets the element at the front of the queue without removing it.\n");
  225.     printf("\n-> display() - it will display the values of stack form top to bottom serially\n");
  226.     printf("\nFor better understand go to this link : https://pastebin.com/Qd89ArTy\n");
  227. }
  228.  
  229. void stack()
  230. {
  231.     int stack[stack_max];
  232.     int top = -1;
  233.     int op;
  234.     printf("\t\t1.push\n\t\t2.pop\n\t\t3.Peek\n\t\t4.Display\n\t\t0. To exit\n\nEnter your choise : ");
  235.     scanf("%d", &op);
  236.     while(op)
  237.     {
  238.     int value, item;
  239.     if(op == 1)
  240.     {
  241.         if(top == stack_max){
  242.             printf("stack is full\n");
  243.         }
  244.         else{
  245.         printf("Enter item : ");
  246.         scanf("%d", &value);
  247.         top++;
  248.         stack[top] = value;
  249.         }
  250.     }
  251.     else if(op == 2)
  252.     {
  253.         if(top == -1){
  254.             printf("Stack is empty\n");
  255.         }
  256.         else{
  257.         item = stack[top];
  258.         printf("%d\n", item);
  259.         top--;
  260.         }
  261.     }
  262.     else if(op == 3)
  263.     {
  264.         if(top == -1) printf("Stack is empty\n");
  265.         printf("%d\n", stack[top]);
  266.     }
  267.     else if(op == 4)
  268.     {
  269.         for(int temp = top; temp>=0; temp--)
  270.         {
  271.             printf("%d\n", stack[temp]);
  272.         }
  273.     }
  274.     printf("\t\t1.push\n\t\t2.pop\n\t\t3.Peek\n\t\t4.Display\n\nEnter your choise : ");
  275.     scanf("%d", &op);
  276.     }
  277. }
  278.  
  279. int binary_search(int *A, int n, int x)
  280. {
  281.     int left = 0, right = n-1, mid;
  282.     while(left<=right)
  283.     {
  284.         mid = left+(right-left)/2;
  285.         if(A[mid] == x){
  286.             return mid;
  287.         }
  288.         if(A[mid]<x) left = mid+1;
  289.         else right = mid-1;
  290.     }
  291.     return -1;
  292. }
  293.  
  294. int sort(const void * a, const void * b)
  295. {
  296.     return (*(int *)a - *(int *)b);
  297. }
  298.  
  299. void linear_search()
  300. {
  301.     int *A, n, x;
  302.     printf("\nEnter how many numbers you take in the array : ");
  303.     scanf("%d", &n);
  304.     A = (int *)calloc(n, sizeof(int));
  305.     printf("\nEneter Numbers : ");
  306.     for(int i=0; i<n; i++){
  307.     scanf("%d", &A[i]);
  308.     }
  309.     printf("\nEnter the Number your are looking for : ");
  310.     scanf("%d", &x);
  311.     for(int i = 0; i < n; i++){
  312.         if(A[i] == x){
  313.             printf("%d is the %dth number of the array\n", x, i+1);
  314.             return;
  315.         }
  316.     }
  317.     printf("%d is not in the array\n");
  318. }
  319.  
  320. void insersion_sort(int A[], int n)
  321. {
  322.     int item, j;
  323.     for(int i=1; i<n; i++){
  324.         item = A[i];
  325.         j = i-1;
  326.         while(j>=0 && A[j]>item)
  327.         {
  328.             A[j+1] = A[j];
  329.             j = j-1;
  330.         }
  331.         A[j+1] = item;
  332.         for(int j=0; j<n; j++){
  333.         printf("%d ", A[j]);
  334.         }
  335.         printf("\n");
  336.     }
  337. }
  338.  
  339. void brute_fonce()
  340. {
  341.     int arr[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 1};
  342.     int arr_count = 10;
  343.     int n = arr[arr_count - 1];
  344.     for(int i = (arr_count - 2); i>=0; i--)
  345.     {
  346.         if(arr[i] >= n)
  347.         {
  348.             int temp = arr[i];
  349.             arr[i+1] = arr[i] = temp;
  350.             for(int j = 0; j<arr_count; j++)
  351.             {
  352.                 printf("%d ", arr[j]);
  353.             }
  354.             printf("\n");
  355.         }
  356.         else if(arr[i]<n)
  357.         {
  358.             arr[i+1] = n;
  359.             for(int j = 0; j<arr_count; j++)
  360.             {
  361.                 printf("%d ", arr[j]);
  362.             }
  363.             break;
  364.         }
  365.     }
  366.     if(arr[0] > n){
  367.         arr[0] = n;
  368.         for(int j = 0; j<arr_count; j++)
  369.         {
  370.             printf("%d ", arr[j]);
  371.         }
  372.     }
  373. }
  374.  
  375. void bubble_sort(int A[], int n)
  376. {
  377.     int temp, count=0;
  378.     for(int i=0; i<n-1; i++){
  379.         //if(i == n-1) break;
  380.  
  381.         for(int j=0; j<n-i-1; j++){//here n-i-1 is using because last one is not needed here
  382.             count++;
  383.  
  384.             if(A[j]>A[j+1]){
  385.             temp = A[j];
  386.             A[j] = A[j+1];
  387.             A[j+1] = temp;
  388.             }
  389.  
  390.             for(int i=0; i<n; i++){
  391.                 printf("%d ", A[i]);
  392.             }
  393.             printf("\n");
  394.         }
  395.     }
  396. }
  397.  
  398. void selection_sort(int A[], int n)
  399. {
  400.     int temp;
  401.     for(int i=0; i<n-1; i++){// here you can use n also but the loop will perfrom extra one time which is not neccesary bcz last elemet will be the larger one autometically
  402.         int index_min = i;
  403.  
  404.         for(int j=i+1; j<n; j++){
  405.             if(A[j] < A[index_min]) index_min = j;
  406.         }
  407.  
  408.         if(index_min != i){
  409.             temp = A[i];
  410.             A[i] = A[index_min];
  411.             A[index_min] = temp;
  412.         }
  413.  
  414.        for(int i=0; i<n; i++){
  415.         printf("%d ", A[i]);
  416.     }
  417.  
  418.     printf("\n");
  419.     }
  420. }
  421.  
  422. void learner()
  423. {
  424.     system("CLS");
  425.     printf("\n\n\n");
  426.     printf("\t\t\tThanks for chosing us!!!\n\t\t----------------------------------------------\n");
  427.     char x = 'y';
  428.     while(x == 'y')
  429.     {
  430.     printf("\n\t\t\tWhat You Want to learn?\n\t\t----------------------------------------------\n\n1.Sorting Algorithms\n2.Searching Algorithms\n3.Stack\n4.Queue\n5.Observe working of singly Linked List\n6.Working process of virtual judge\n");
  431.     int select;
  432.     printf("\nYour selection : ");
  433.     scanf("%d", &select);
  434.     if(select == 1)
  435.     {
  436.         system("CLS");
  437.         printf("\n1.Selection sort\n2.Insertion sort\n3.buble sort\n4.Brute fonce method\n");
  438.         printf("\nYour selection : ");
  439.         scanf("%d", &select);
  440.         system("CLS");
  441.         if(select == 1)
  442.         {
  443.             printf("Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place comparison-based algorithm in which the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end. Initially, the sorted part is empty and the unsorted part is the entire list.");
  444.             printf("The smallest element is selected from the unsorted array and swapped with the leftmost element, and that element becomes a part of the sorted array. This process continues moving unsorted array boundary by one element to the right.");
  445.             printf("This algorithm is not suitable for large data sets as its average and worst case complexities are of Ο(n^2), where n is the number of items.");
  446.             printf("\n\t\tHow selection sort works\n\t----------------------------------------\n");
  447.             printf("Consider the following depicted array as an example. 5 4 3 2 1. we need to sort this array using selection sort process\n");
  448.             printf("\nStep 1 : For the first position in the sorted list, the whole list is scanned sequentially. The first position where 5 is stored presently, we search the whole list and find that 1 is the lowest value. Now we need to swap these two. If we swap these two or after first iterration it is garunteed the lowest value will be in first place. So Number one is sorted.\n");
  449.             printf("\nStep 2 : For the second position in the sorted list, the the whole list is scanned sequentially without first position because its already sorted, we will find the lowest which is 2 and it will go to second place\n.");
  450.             printf("\nStep 3 : This lowest finding process will continue for all these value in the array and swap process will continue and after the all iterration the array will be sorted\n");
  451.             printf("\nfor the avobe mentioned array after every iterration the array will look like\n\n1 4 3 2 5\n\n1 2 3 4 5\n\n1 2 3 4 5\n\n1 2 3 4 5\n");
  452.             printf("Now its your job to write some simple code to implement this algorithm\n\n for better understanding take input and see the every iterration output\n");
  453.             int *C, n2;
  454.             printf("\nEnter how many numbers you take in the array : ");
  455.             scanf("%d", &n2);
  456.             C = (int *)calloc(n2, sizeof(int));
  457.             printf("\nEneter Numbers : ");
  458.             for(int i=0; i<n2; i++){
  459.                 scanf("%d", &C[i]);
  460.             }
  461.             selection_sort(C,n2);
  462.         }
  463.         else if(select == 2)
  464.         {
  465.             printf("Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.\n");
  466.             printf("\nThe array is searched sequentially and unsorted items are moved and inserted into the sorted sub-list (in the same array). This algorithm is not suitable for large data sets as its average and worst case complexity are of Ο(n2), where n is the number of items.\n");
  467.             printf("We take an unsorted array for our example. 5 4 3 2 1\n");
  468.             printf("\nStep 1 : Insertion sort compares the first two elements. smaller one will go to first place. it will look like 4 5 3 2 1\n");
  469.             printf("\nStep 2 : Then we will find the right place for 3. which is before 4. it will look like 3 4 5 2 1\n");
  470.             printf("\nStep 3 : Now we will find out the right place for 2 which is before 3. it will look like 2 3 4 5 1\n");
  471.             printf("\nStep 4 : Now we will find the right place for 1 which is before 2. it will look like 1 2 3 4 5. after this iterraation we will find our sorted array\n");
  472.             printf("\nNow write a simple code for this algorithm first, for better understing take a input array and look at the every iterration\n");
  473.             int *A, n;
  474.             printf("\nEnter how many numbers you take in the array : ");
  475.             scanf("%d", &n);
  476.             A = (int *)calloc(n, sizeof(int));
  477.             printf("\nEneter Numbers : ");
  478.             for(int i=0; i<n; i++){
  479.             scanf("%d", &A[i]);
  480.             }
  481.             insersion_sort(A, n);
  482.         }
  483.         else if(select == 3)
  484.         {
  485.             printf("Bubble sort is a simple sorting algorithm.\n");
  486.             printf("\nThis sorting algorithm is comparison-based algorithm in which each pair of adjacent elements is compared and the elements are swapped if they are not in order.\n");
  487.             printf("\nThis algorithm is not suitable for large data sets as its average and worst case complexity are of Ο(n2) where n is the number of items.\n");
  488.             printf("\nStep 1 : We take an unsorted array for our example. 8 2 4 1 5\n");
  489.             printf("\nStep 2 : Buble sort start working by comparing first two number and smaller one will come to first. 2 8 4 1 5\n");
  490.             printf("\nStep 2 : Then it will compare 2nd and 3rd number and smaller one will come first. 2 4 8 1 5\n");
  491.             printf("\nStep 2 : Then it will compare 3rd and 4th number and smaller one will come first. 2 4 1 8 5\n");
  492.             printf("\nStep 2 : Then it will compare 4th and 5th number and smaller one will come first. 2 4 1 5 8. this is the end of step 2 and first iterration of first loop. And largest value will come up into last place\n");
  493.             printf("\nStep 3 : Same process will go on for every iterration and after every iterration the largest will go into the last place.\n");
  494.             printf("\nNow visualise the algorithm and try to write the code. for better understanding take a input and see the every iterration output\n");
  495.             int *B, n1;
  496.             printf("\nEnter how many numbers you take in the array : ");
  497.             scanf("%d", &n1);
  498.             B = (int *)calloc(n1, sizeof(int));
  499.             printf("\nEneter Numbers : ");
  500.             for(int i=0; i<n1; i++){
  501.                 scanf("%d", &B[i]);
  502.             }
  503.             bubble_sort(B, n1);
  504.         }
  505.         else if(select == 4)
  506.         {
  507.             printf("One common task for computers is to sort data. For example, people might want to see all their files on a computer sorted by size. Since sorting is a simple problem with many different possible solutions, it is often used to introduce the study of algorithms.\n");
  508.             printf("\nGiven a sorted list with an unsorted number  in the rightmost cell, can you write some simple code to insert  into the array so that it remains sorted?\n");
  509.             printf("\nSince this is a learning exercise, it won't be the most efficient way of performing the insertion. It will instead demonstrate the brute-force method in detail.\n");
  510.             printf("\nAssume you are given the array arr = [1, 2, 4, 5, 3]  indexed 0 to 4. Store the value of arr[4].\n");
  511.             printf("\nNow test lower index values successively from 3 to 0 until you reach a value that is lower than arr[4],arr[1] in this case.\n");
  512.             printf("\nEach time your test fails, copy the value at the lower index to the current index and print your array.\n");
  513.             printf("\nWhen the next lower indexed value is smaller than arr[4], insert the stored value at the current index and print the entire array.\n");
  514.             printf("\nThe results of operations on the example array is: \n");
  515.             printf("\nStarting array: [1, 2, 4, 5, 3]\n");
  516.             printf("\nStore the value of arr[4] = 3 Do the tests and print interim results: \n");
  517.             printf("\n1 2 4 5 5\n1 2 4 4 5\n1 2 3 4 5\n");
  518.             printf("for better understanding look at another example given\n");
  519.             brute_fonce();
  520.         }
  521.     }
  522.     else if(select == 2)
  523.     {
  524.         system("CLS");
  525.         printf("1.Linear Search\n2.Binary Search\n");
  526.         printf("\nYour selection : ");
  527.         scanf("%d", &select);
  528.         system("CLS");
  529.         if(select == 1)
  530.         {
  531.             printf("\nLinear search is a very simple search algorithm. In this type of search, a sequential search is made over all items one by one.\n");
  532.             printf("\nEvery item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection.\n");
  533.             printf("\nLinear Search ( Array A, Value x)\nStep 1: Set i to 1\nStep 2: if i > n then go to step 7\nStep 3: if A[i] = x then go to step 6\nStep 4: Set i to i + 1.");
  534.             printf("\nStep 5: Go to Step 2\nStep 6: Print Element x Found at index i and go to step 8\nStep 7: Print element not found\nStep 8: Exit\n");
  535.             printf("\nNow try to understand the algorithm and write down the simple code for it. for better understanding take a input array and search that\n");
  536.             linear_search();
  537.         }
  538.         else if(select == 2)
  539.         {
  540.             printf("\nBinary search is a fast search algorithm with run-time complexity of Ο(log n).\n");
  541.             printf("\nThis search algorithm works on the principle of divide and conquer. For this algorithm to work properly, the data collection should be in the sorted form.\n");
  542.             printf("\nBinary search looks for a particular item by comparing the middle most item of the collection. If a match occurs, then the index of item is returned.\n");
  543.             printf("\n If the middle item is greater than the item, then the item is searched in the sub-array to the left of the middle item. Otherwise, the item is searched for in the sub-array to the right of the middle item.\n");
  544.             printf("\nThis process continues on the sub-array as well until the size of the subarray reduces to zero.\n");
  545.             printf("\nGiven an array A of n elements with values or records  A_{0},A_{1},A_{2},......,A_{n-1} sorted such that A_{0} <= A_{1} <= {2} <= ........<= A_{n-1} and target value T, the following subroutine uses binary search to find the index of T in A\n");
  546.             printf("\nSetp 1 : Set L to 0 and R to n-1.\n");
  547.             printf("\nSetp 2 : If  L>R, the search terminates as unsuccessful.\n");
  548.             printf("\nSetp 3 : Set m (the position of the middle element) to the floor of (L+R)/2, which is the greatest integer less than or equal to  (L+R)/2.\n");
  549.             printf("\nSetp 4 : If  A_m < T, set L to  m+1 and go to step 2.\n");
  550.             printf("\nSetp 5 : If  A_m > T, set R to  m-1 and go to step 2.\n");
  551.             printf("\nSetp 6 : Now A_m = T, the search is done; return m\n");
  552.             printf("\nNow try to write some code by own and for better understanding take a input array and see the output. try to make a code which gives the same kind of output\n");
  553.             int *A, n, x;
  554.             printf("\nEnter how many numbers you take in the array : ");
  555.             scanf("%d", &n);
  556.             A = (int *)calloc(n, sizeof(int));
  557.             printf("\nEneter Numbers : ");
  558.             for(int i=0; i<n; i++){
  559.                 scanf("%d", &A[i]);
  560.             }
  561.             qsort(A, n, sizeof(int), sort);
  562.             for(int i=0; i<n; i++){
  563.                 printf("%d ", A[i]);
  564.             }
  565.             printf("\nEneter the Number you are searching in the array : ");
  566.             scanf("%d", &x);
  567.             int z = binary_search(A, n, x);
  568.             if(z == -1) printf("\nThere is no number like %d\n", x);
  569.             else printf("\n%d is the %dth number of the array\n", x, z+1);
  570.         }
  571.     }
  572.     else if(select == 3)
  573.     {
  574.         system("CLS");
  575.         int choise;
  576.         printf("\nA stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example – a deck of cards or a pile of plates, etc.\n");
  577.         printf("\nA real-world stack allows operations at one end only. For example, we can place or remove a card or plate from the top of the stack only. Likewise, Stack ADT allows all data operations at one end only. At any given time, we can only access the top element of a stack.\n");
  578.         printf("\nThis feature makes it LIFO data structure. LIFO stands for Last-in-first-out.\n");
  579.         printf("\nHere, the element which is placed (inserted or added) last, is accessed first.\n");
  580.         printf("\nIn stack terminology, insertion operation is called PUSH operation and removal operation is called POP operation.\n");
  581.         printf("\nA stack can be implemented by means of Array, Structure, Pointer, and Linked List. Stack can either be a fixed size one or it may have a sense of dynamic resizing. Here, we are going to implement stack using arrays, which makes it a fixed size stack implementation.\n");
  582.         printf("\n\t\tBasic Operations\n\t------------------------------------------\n");
  583.         printf("\nStack operations may involve initializing the stack, using it and then de-initializing it. Apart from these basic stuffs, a stack is used for the following two primary operations −\n");
  584.         printf("\n-> push() − Pushing (storing) an element on the stack. New item will added at top position\n");
  585.         printf("\n-> pop() − Removing (accessing) an element from the stack. item will be removed from top position\n");
  586.         printf("\n-> peek() − get the top data element of the stack, without removing it. this will print us the top position value of stack\n");
  587.         printf("\n-> display() - it will display the values of stack form top to bottom serially\n");
  588.         printf("\nNow try to implement the algorithm decribed above.\n");
  589.         printf("\nFor better understanding you can go to stack function to observe the working process\n");
  590.         printf("\n\t1.Yes\n\t2.No\nDo you want to observe the process : ");
  591.         scanf("%d", &choise);
  592.         if(choise == 1)stack();
  593.     }
  594.     else if(select == 4)
  595.     {
  596.         system("CLS");
  597.         printf("\nQueue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends.\n");
  598.         printf("\nOne end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.\n");
  599.         printf("\nA real-world example of queue can be a single-lane one-way road, where the vehicle enters first, exits first. More real-world examples can be seen as queues at the ticket windows and bus-stops.\n");
  600.         printf("\nAs we now understand that in queue, we access both ends for different reasons. The following diagram given below tries to explain queue representation as data structure −\n");
  601.         printf("\nAs in stacks, a queue can also be implemented using Arrays, Linked-lists, Pointers and Structures. For the sake of simplicity, we shall implement queues using one-dimensional array.\n");
  602.         printf("\nQueue operations may involve initializing or defining the queue, utilizing it, and then completely erasing it from the memory. Here we shall try to understand the basic operations associated with queues −\n");
  603.         queue();
  604.     }
  605.     else if(select == 5)
  606.     {
  607.     system("CLS");
  608.     Node *head=0, *temp;
  609.     int choise;
  610.     printf("Enter How many node you want to Insert : ");
  611.     scanf("%d", &choise);
  612.     printf("\n");
  613.     for(int i = 0; i < choise; i++){
  614.     Node *new_node = (Node *)malloc(sizeof(Node));
  615.     printf("Enter Node item for %d : ", i+1);
  616.     scanf("%d", &new_node->data);
  617.     new_node->next = NULL;
  618.  
  619.     if(head == NULL){
  620.         head = temp = new_node;
  621.     }
  622.     else{
  623.         temp->next = new_node;
  624.         temp = new_node;
  625.     }
  626.     }
  627.  
  628.     printf("\nThis is Your created linked list : ");
  629.     print_linked_list(head);
  630.  
  631.     gotoxy(30,10); /// move the cursor to postion 30, 10 from top-left corner
  632.     printf("1. Insert at Nth position"); /// option for add record
  633.     gotoxy(30,12);
  634.     printf("2. Delete at Nth position"); /// option for showing existing record
  635.     gotoxy(30,14);
  636.     printf("3. Print List");
  637.  
  638.     int op;
  639.     printf("Enter Your Choise(0 to exit) : ");
  640.     scanf("%d", &op);
  641.     while(op)
  642.     {
  643.         if(op == 1){
  644.             choise++;
  645.             int option;
  646.             printf("Enter the place where you want to insert\n\n\t1.First position\n\t2.Last position\n\t3.After Nth position\n\n : ");
  647.             scanf("%d", &option);
  648.             if(option == 1) head = prepend(head);
  649.             else if(option == 2) append(head);
  650.             else if(option == 3) add_node(head);
  651.         }
  652.         else if(op == 2){
  653.             head = remove_node(head, choise);
  654.         }
  655.         else if(op == 3){
  656.             print_linked_list(head);
  657.         }
  658.         printf("\n1. Insert at Nth position"); /// option for add record
  659.         printf("\n2. Delete at Nth position"); /// option for showing existing record
  660.         printf("\n3. Print List");
  661.         printf("Enter Your Choise(0 to exit) : ");
  662.         scanf("%d", &op);
  663.     }
  664.     }
  665.     else if(select == 6)
  666.     {
  667.         system("CLS");
  668.         virtual_judge();
  669.     }
  670.     printf("\nDo you want to learn more(y/n) : ");
  671.     x = getche();
  672.     system("CLS");
  673.     }
  674. }
  675.  
  676. void learn_or_findjob()
  677. {
  678.     printf("\t\t\tWhy You Are Here\n\t\t------------------------------\n\t\t\t1.Learner\n\t\t\t2.Find Job\n");
  679.     int option;
  680.     printf("\n\t\tEnter Your Option : ");
  681.     scanf("%d", &option);
  682.     if(option == 1)
  683.     {
  684.         learner();
  685.     }
  686.     else{
  687.         find_job();
  688.     }
  689. }
  690.  
  691. int Login()
  692. {
  693.     FILE *LOG;
  694.     LOG = fopen("login.txt", "r");
  695.     if(LOG == NULL){
  696.         perror("File opening failed!");
  697.         return 0;
  698.     }
  699.     printf("\n\t\t\tWelcome to login section\n\t\t--------------------------------------------------\n");
  700.     char check_userid_pass[20];
  701.     char userId[20];
  702.     char pass2[20];
  703.     int count = 0;
  704.     printf("\tEnter User id  : ");
  705.     scanf(" %[^\n]", &userId);
  706.     printf("\tEnter Password : ");
  707.     scanf(" %[^\n]", &pass2);
  708.  
  709.     while(fscanf(LOG, "%s", &check_userid_pass) != EOF)
  710.     {
  711.         if(strcmp(userId, check_userid_pass) == 0) count++;
  712.         if(strcmp(pass2, check_userid_pass) == 0) count++;
  713.     }
  714.     if(count <= 1)return 0;
  715.     else return 1;
  716.  
  717. }
  718.  
  719. void registration()
  720. {
  721.     printf("\t\tWelcome to the registration section\n\t----------------------------------------------------\n");
  722.     FILE *LOG;
  723.     LOG = fopen("login.txt", "a");
  724.  
  725.     if(LOG == NULL){
  726.         perror("File opening failed!");
  727.         return;
  728.     }
  729.     struct Registration p;
  730.  
  731.     printf("\t\tEnter your first name     : ");
  732.     scanf("%s", &p.first_name);
  733.     //fprintf(LOG, "%s\n", p.first_name);
  734.  
  735.     printf("\t\tEnter your last name      : ");
  736.     scanf("%s", &p.last_name);
  737.     //fprintf(LOG, "%s\n", p.last_name);
  738.  
  739.     printf("\t\tEnter your Email          : ");
  740.     scanf(" %[^\n]", &p.email);
  741.     //fprintf(LOG, "%s\n", p.email);
  742.  
  743.     printf("\t\tEnter your User Id        : ");
  744.     scanf(" %[^\n]", &p.user_id);
  745.     fprintf(LOG, "%s\n", p.user_id);
  746.  
  747.     printf("\t\tEnter your password       : ");
  748.     scanf(" %[^\n]", &p.password);
  749.     fprintf(LOG, "%s\n", p.password);
  750.  
  751.     printf("\t\tEnter your password Again : ");
  752.     scanf(" %[^\n]", &p.confirm_pass);
  753.     //fprintf(LOG, "%s\n", p.confirm_pass);
  754.  
  755.     if(strcmp(p.password, p.confirm_pass) == 0)
  756.     {
  757.         printf("\n\t\tYour registration is successful!!\n\t------------------------------------------------------\n");
  758.         //getch();
  759.         system("CLS");
  760.         fclose(LOG);
  761.         //fflush(stdin);
  762.         if(Login())
  763.         {
  764.            system("CLS");
  765.            printf("\nLogin successsful\n");
  766.            printf("\n\n\n\n");
  767.            learn_or_findjob();
  768.         }
  769.         else{
  770.              printf("INVALID!!!!!!!!!\n");
  771.         }
  772.     }
  773.     else{
  774.         printf("Your password doesn't match!!!!! your registration is not successful!\n");
  775.     }
  776. }
  777.  
  778. void Starting_of_software()
  779. {
  780.     printf("\t\tWelcome to the Leanning Platform and Find Job Software\n\t---------------------------------------------------------------------\n\n");
  781.     printf("\t\t1. Are You a New User?\n\t\t2. Already Have An Account?\n\n");
  782.     int choise;
  783.     printf("Enter Your choise : ");
  784.     scanf("%d", &choise);
  785.     if(choise == 1)
  786.     {
  787.         system("CLS");
  788.         printf("\n");
  789.         registration();
  790.     }
  791.     else if(choise == 2)
  792.     {
  793.         printf("\n");
  794.         system("CLS");
  795.         if(Login())
  796.         {
  797.            system("CLS");
  798.            printf("\nLogin successsful\n");
  799.            printf("\n\n\n\n");
  800.            learn_or_findjob();
  801.         }
  802.         else{
  803.              printf("INVALID!!!!!!!!!\n");
  804.         }
  805.     }
  806. }
  807.  
  808. int main()
  809. {
  810.     Starting_of_software();
  811.     return 0;
  812. }
  813.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement