Advertisement
Guest User

Katy

a guest
Dec 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. int n,m,k=0,h=0;
  5. cout<<"enter n,m"<<endl;
  6. cin>>n>>m;
  7. int **a=new int*[n];
  8. int **b=new int*[n];
  9. for(int i=0;i<n;++i){
  10. a[i]=new int[m];
  11. b[i]=new int[m];}
  12. cout<<"enter array"<<endl;
  13. for(int i=0;i<n;++i){
  14. for(int j=0;j<m;++j){
  15. cin>>a[i][j];}}
  16. for(int i=0;i<n;++i){
  17. bool flag=true;
  18. for(int j=0;j<m;++j){
  19. if(a[i][j]%2==0){
  20. flag=false;
  21. break;}
  22. }
  23. if(flag==true){
  24. for(int j=0;j<m;++j){
  25. b[k][j]=a[i][j];}
  26. ++k;}}
  27. cout<<"Array : "<<endl;
  28. for(int i=0;i<k;++i){
  29. for(int j=0;j<m;++j){
  30. cout<<b[i][j]<<" ";}
  31. cout<<endl;}
  32. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement