#include<iostream>
using namespace std;
#include<conio.h>
#include<stdio.h>
inline void nhapmang(int *a, int n)
{
for(int i=0;i<n;i++)
{
cout<<"nhapn vao a["<<i<<"] = ";cin>>*(a++);
}
}
inline void xuatmang(int *a,int n)
{
for( int i=0;i<n;i++)
{
cout<<*(a++)<<" ";
}
}
int main()
{
int n;
do{
cout<<"nhap vao so luong phan tu trong mang";cin>>n;
if(n<0)
{
cout<<"\nso luon phan tu ban nhap bi sai moi kiem tra lai ! ";
}
}while(n<0);
//int *a=new int[n];
int *a=(int *)malloc(n*sizeof(int *));
nhapmang(a,n);
cout<<endl;
xuatmang(a,n);
free a;
//delete[] a;
getch();
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.