Need To Know Algoritims
Need To Know Algoritims
#include <iostream>
int main()
{
int Arr[] = {10,5,12,45,60,90};
int pos1 = -1;
int pos2 = -1;
for(int i = 0; i < 6; i++){
if(*(Arr+i)==10){
pos1 = i;
}
if(*(Arr +i) == 60){
pos2 = i;
}
}
#include <iostream>
using namespace std;
int main()
{
int size;
cout<<"What is the array size";
cin>> size;
int Arr[size];
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int DArr[3][3];
DArr[i][j] = x;
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
cout<<DArr[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
Output:
#include <iostream>
using namespace std;
int main()
{
int rows, collums;
cin>>rows>>collums;
//deallocation
for(int j = 0; j <rows; j++){
delete[]table[j];//must first deallocate all the arrays in
the array
}
delete []table;
table = NULL;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int rows, collums;
cout<<"Enter the amount of rows then the amount of
collums"<<endl;
cin>>rows>>collums;
//deallocation
for(int j = 0; j <rows; j++){
delete[]table[j];//must first deallocate all the arrays in
the array
}
delete []table;
table = NULL;
return 0;
}