Posts

Showing posts from June, 2022

String matching

 #include<stdio.h>   int main() {     char str[80];     int count1 = 0, count2 = 0, i, j;     char start , end ;      printf("Enter a string:");     gets(str);     printf("enter first character\n");     scanf(" %c", &start);      printf("enter 2nd character\n");     scanf(" %c", &end);     while (str[count1] != '\0')         count1++;         for (i = 0; i <= count1 ; i++)     {         for (j = count1; j > i ; j--) {                              if( (str[i]== start && str[j]== end) || ( str[i]== end && str[j]== start)){                 count2++;               for(int k = i ; k <= j ; k++){       ...

Hashing

#include <stdio.h>       void selection(int data[], int n, int stu[]) {       int i, j, small;              for (i = 1; i < n; i++) {           small = i; //minimum element in unsorted array                      for (j = i; j <= n; j++) {          if (data[j] < data[small]) {             small = j;           }    }    int temp = data[small];       data[small] = data[i];       data[i] = temp;         temp = stu[small];       stu[small] = stu[i];       stu[i] = temp;            }   }     int main() { int n ; printf("enter no of student\n"); scanf("%d...