using namespace std
using namespace std
int main() {
int sparseMatrix[4][5] = {
{0 , 0 , 3 , 0 , 4 },
{0 , 0 , 5 , 7 , 0 },
{0 , 0 , 0 , 0 , 0 },
{0 , 2 , 6 , 0 , 0 }
};
int size = 0;
if (sparseMatrix[i][j] != 0)
size++;
int compactMatrix[3][size];
int k = 0;
if (sparseMatrix[i][j] != 0)
compactMatrix[0][k] = i;
compactMatrix[1][k] = j;
compactMatrix[2][k] = sparseMatrix[i][j];
k++;
cout <<"\n";
return 0;
2nd
#include<iostream>
if (arr[i] == x)
return i;
return -1;
int main()
int x = 10;
(result == -1)
return 0;
}
2nd
#include<iostream>
if (arr[mid] == x)
return mid;
if (arr[mid] < x)
low = mid + 1;
else
high = mid - 1;
return -1;
int main()
int x = 10;
return 0;
}
2nd
2nd
2nd
2nd
2nd
2nd