Snippets Collections
<!DOCTYPE html>
<html lang="en">
<head>
    <style>

body {
    background-color: lightblue;
  }
  h3{background-color: aliceblue;text-align: center;text-decoration: dotted;

  }
  h1{
    text-decoration: double;background-color: azure;
  }
div{
    align-items: center;
}
a{
    align-items: center;
}
div{
    text-align: left;background-color: aquamarine;position: static;align-items: right;
    border: 3px solid #73AD21;
}


    </style>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div style="position: fixed;right: 0px;">
     username: <input placeholder="enter user id">
    <br>
    <br>
    password: <input type="password" placeholder="enter your password">
    </div>
    <h1 style="color: red;text-align: center;"> PRODUCT DETAIL:- </h1>
    <h3 style="text-align:center;color: black;">Samsung Galaxy M34 5G (Midnight Blue, 6GB, 128GB Storage) | 120Hz sAMOLED Display | 50MP Triple No Shake Cam | 6000 mAh Battery | 12GB RAM with RAM Plus | Android 13 | Without Charger</h3>
    <h1 style="text-align: center;color: rgb(30, 32, 32);">name:-</h1>
    <p style="text-align: center;color: brown;"> samsung m3</p>
    <h2>About this item:-</h2>
    <p style="text-align: center;text-decoration: dotted; background-color: blueviolet;">
        Exynos 1280 Octa Core 2.4GHz with the 12 band support for a True 5G experience
        16.42 centimeters (6.5-inch) Super AMOLED Display, FHD+ resolution, 1080 x 2340 pixels protected by Gorilla Glass 5
        50MP+8MP+2MP Triple Camera Setup - True 50MP No Shake Cam (F1.8) Main Camera + 8MP (F2.2) + 2MP (F2.4)| 13MP (F2.0) Front Camera
        6000mAH lithium-ion battery, 1 year manufacturer warranty for device and 6 months manufacturer warranty for in-box accessories including batteries from the date of purchase
        4 Generations of OS Upgrades and 5 Years of Security Updates</p>
        <div>
    <a href="https://www.amazon.in/Samsung-Midnight-Storage-sAMOLED-Display/dp/B0C7BZX934/ref=lp_4363159031_1_1?sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D"> <img style="align-items: center;" src="https://m.media-amazon.com/images/I/91fonhAtoAL._AC_UL320_.jpg" alt=""></a>
</div>
</html>
#include <stdio.h>

struct Item {
    char name[50];
    float price;
    int quantity;
};

float calculateTotal(struct Item items[], int itemCount) {
    float total = 0.0;
    for (int i = 0; i < itemCount; i++) {
        total += items[i].price * items[i].quantity;
    }
    return total;
}

float calculateDiscountedTotal(float total, float discount) {
    return total - (total * discount / 100);
}

float calculateRemainingCash(float total, float cashInput) {
    return cashInput - total;
}

void displayBill(struct Item items[], int itemCount, float total, float discount, float cashInput, float remainingCash) {
    printf("\n********** BILL **********\n");
    printf("Item\t\tPrice\tQuantity\n");
    printf("----------------------------\n");
    for (int i = 0; i < itemCount; i++) {
        printf("%s\t\t%.2f\t%d\n", items[i].name, items[i].price, items[i].quantity);
    }
    printf("----------------------------\n");
    printf("Total: %.2f\n", total);
    printf("Discount: %.2f%%\n", discount);
    printf("Discounted Total: %.2f\n", calculateDiscountedTotal(total, discount));
    printf("Cash Input: %.2f\n", cashInput);
    printf("Remaining Cash: %.2f\n", remainingCash);
    printf("****************************\n");
}

int main() {
    int itemCount;
    printf("Enter the number of items: ");
    scanf("%d", &itemCount);

    struct Item items[itemCount];

    printf("Enter the details of each item:\n");
    for (int i = 0; i < itemCount; i++) {
        printf("Item %d:\n", i + 1);
        printf("Name: ");
        scanf("%s", items[i].name);
        printf("Price: ");
        scanf("%f", &items[i].price);
        printf("Quantity: ");
        scanf("%d", &items[i].quantity);
    }

    float total = calculateTotal(items, itemCount);

    float discount;
    printf("Enter discount percentage: ");
    scanf("%f", &discount);

    float cashInput;
    printf("Enter cash input: ");
    scanf("%f", &cashInput);

    float remainingCash = calculateRemainingCash(calculateDiscountedTotal(total, discount), cashInput);

    displayBill(items, itemCount, total, discount, cashInput, remainingCash);

    return 0;
}
#include <stdio.h>

void printArray(int *A, int n)
{
    for (int i = 0; i < n; i++)
    {
        printf("%d ", A[i]);
    }
    printf("\n");
}

void merge(int A[], int mid, int low, int high)
{
    int i, j, k, B[100];
    i = low;
    j = mid + 1;
    k = low;

    while (i <= mid && j <= high)
    {
        if (A[i] < A[j])
        {
            B[k] = A[i];
            i++;
            k++;
        }
        else
        {
            B[k] = A[j];
            j++;
            k++;
        }
    }
    while (i <= mid)
    {
        B[k] = A[i];
        k++;
        i++;
    }
    while (j <= high)
    {
        B[k] = A[j];
        k++;
        j++;
    }
    for (int i = low; i <= high; i++)
    {
        A[i] = B[i];
    }
    
}

void mergeSort(int A[], int low, int high){
    int mid; 
    if(low<high){
        mid = (low + high) /2;
        mergeSort(A, low, mid);
        mergeSort(A, mid+1, high);
        merge(A, mid, low, high);
    }
}

int main()
{
    // int A[] = {9, 14, 4, 8, 7, 5, 6};
    int A[] = {9, 1, 4, 14, 4, 15, 6};
    int n = 7;
    printArray(A, n);
    mergeSort(A, 0, 6);
    printArray(A, n);
    return 0;
}
#include<stdio.h>
#include<stdlib.h>

int graph[10][10], visited[10],total,arr[30];
static int k=0,count=0;
void DFS(int);
main()
{
	int i,j;
	printf("\nEnter the total number of vertices in graph\n");
	scanf("%d",&total);
	/*Adjacency matrix input*/
	printf("\nEnter the adjacency matrix\n");
	for(i=0;i<total;i++)
	{
		for(j=0;j<total;j++)
		{
			scanf("%d",&graph[i][j]);
		}
	}
	for(i=0;i<total;i++)
	{
		visited[i] = 0;
	}
	printf("\nDFS traversal is \n");
	DFS(0);
}
void DFS(int vertex)
{
	int j,c=0;
	count++;
	printf("%d\t",vertex);
	visited[vertex] = 1;
	for(j=0;j<total;j++)
	{
		if(!visited[j] && graph[vertex][j] == 1)
		{
			arr[++k] = j;
			c=1;
		}
		if(count == total)
		{
			exit(0);
		}
	}
	if(c==1)
	{
		DFS(arr[k]);
	}
	else
	{
		k--;
		DFS(arr[k]);
	}	
}
#include<stdio.h>

void BFS(int);
int graph[10][10], visited[10],total;

main()
{
	int i,j;
	printf("\nEnter the total number of vertices in graph\n");
	scanf("%d",&total);
	/*Adjacency matrix input*/
	printf("\nEnter the adjacency matrix\n");
	for(i=0;i<total;i++)
	{
		for(j=0;j<total;j++)
		{
			scanf("%d",&graph[i][j]);
		}
	}
	for(i=0;i<total;i++)
	{
		visited[i] = 0;
	}
	printf("\nBFS traversal is \n");
	BFS(0);
}
void BFS(int vertex)
{
	int j;
	printf("%d\t",vertex);
	visited[vertex] = 1;
	for(j=0;j<total;j++)
	{
		if(!visited[j] && graph[vertex][j] == 1 )
		{
			BFS(j);
		}
	}
}
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
 
int i, j, k, a, b, u, v, n, ne = 1;
int min, mincost = 0, cost[9][9], parent[9];
 
int find(int);
int uni(int, int);
 
void main()
{
  printf("Kruskal's algorithm in C\n");
  printf("========================\n");
 
  printf("Enter the no. of vertices:\n");
  scanf("%d", &n);
 
  printf("\nEnter the cost adjacency matrix:\n");
  for (i = 1; i <= n; i++)
  {
    for (j = 1; j <= n; j++)
    {
      scanf("%d", &cost[i][j]);
      if (cost[i][j] == 0)
        cost[i][j] = 999;
    }
  }
 
  printf("The edges of Minimum Cost Spanning Tree are\n");
  while (ne < n)
  {
    for (i = 1, min = 999; i <= n; i++)
    {
      for (j = 1; j <= n; j++)
      {
        if (cost[i][j] < min)
        {
          min = cost[i][j];
          a = u = i;
          b = v = j;
        }
      }
    }
 
    u = find(u);
    v = find(v);
 
    if (uni(u, v))
    {
      printf("%d edge (%d,%d) =%d\n", ne++, a, b, min);
      mincost += min;
    }
 
    cost[a][b] = cost[b][a] = 999;
  }
 
  printf("\nMinimum cost = %d\n", mincost);
  getch();
}
 
int find(int i)
{
  while (parent[i])
    i = parent[i];
  return i;
}
 
int uni(int i, int j)
{
  if (i != j)
  {
    parent[j] = i;
    return 1;
  }
 
  return 0;
}
star

Wed Aug 23 2023 17:03:49 GMT+0000 (Coordinated Universal Time)

#algo #search #dfs
star

Fri May 26 2023 11:18:16 GMT+0000 (Coordinated Universal Time)

#algo #search #dfs
star

Tue May 23 2023 18:14:51 GMT+0000 (Coordinated Universal Time)

#algo #search #dfs
star

Mon May 22 2023 12:45:36 GMT+0000 (Coordinated Universal Time)

#algo #search #dfs
star

Mon May 22 2023 12:25:11 GMT+0000 (Coordinated Universal Time)

#algo #bfs #search
star

Mon May 22 2023 08:07:59 GMT+0000 (Coordinated Universal Time)

#krushkal #algo

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension