-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPrg 9.cpp
49 lines (39 loc) · 947 Bytes
/
Prg 9.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
Lab Program 9
Sparse Martix Search
Author Strider24/SkyKOG
*/
#include <stdio.h>
#include <conio.h>
typedef struct
{
int row;
int column;
int value;
}Element;
void main()
{
Element E[10];
int count, key, i;
printf("Enter the Number of Non Zero Entities In The Sparse Matrix: ");
scanf("%d", &count);
printf("\n");
for(i = 0; i < count; i++)
{
printf("\nEnter Data For Element %d in <row,column,value> Format : ",i+1);
scanf("%d", &E[i].row);
scanf("%d", &E[i].column);
scanf("%d", &E[i].value);
}
printf("\n\nEnter the element to search for : ");
scanf("%d", &key);
for(i = 0; i < count; i++)
if(E[i].value == key)
{
printf("\nThe element %d Is Found At Row %d And Column %d", key, E[i].row, E[i].column);
break;
}
if(i == count)
printf("\nElement Not Found");
getch();
}