forked from AllAlgorithms/cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeleteRowSparseMatrix.cpp
More file actions
53 lines (52 loc) · 1.67 KB
/
Copy pathDeleteRowSparseMatrix.cpp
File metadata and controls
53 lines (52 loc) · 1.67 KB
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
50
51
52
53
#include "triplet.h"
int main() {
int c, val, row, col;
while (1) {
printf("--------------------------------\n");
printf("1. Initialize Sparse Matrix(Triplet).\n");
printf("2. Display Matrix.\n");
printf("3. Insert element in Sparse Matrix.\n");
printf("4. Delete element in Sparse Matrix.\n");
printf("5. Delete the i-th row from the Sparse Matrix.\n");
printf("10. Exit.\n");
printf("Enter your choice: ");
scanf("%d", &c);
switch (c) {
case 1:
printf("Enter number of rows to insert:");
scanf("%d", &row);
printf("Enter number of columns to insert:");
scanf("%d", &col);
init(row, col);
break;
case 2:
display();
break;
case 3:
printf("Enter value to insert:");
scanf("%d", &val);
printf("At row = ");
scanf("%d", &row);
printf("At column = ");
scanf("%d", &col);
insert(val, row, col);
break;
case 4:
printf("Enter row of element to delete:");
scanf("%d", &row);
printf("Enter column of element to delete:");
scanf("%d", &col);
delete(row, col);
break;
case 5:
printf("Enter row to delete:");
scanf("%d", &row);
deleteRow(row);
break;
case 10:
return 0;
default:;
}
}
return 0;
}