bai 141 lap trinh mang
Page 1 of 1
bai 141 lap trinh mang
// stdafx.cpp : source file that includes just the standard includes
// Itec.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "iostream"
using namespace std;
void nhap(int a[],int &n)
{
cout<<"Nhap so luong phan tu cua mang:";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Nhap a["<<i<<"]:";
cin>>a[i];
}
}
void xuat(int a[],int n)
{
cout<<"Xuat mang :";
for(int i=0;i<n;i++)
{
cout<<" "<<a[i];
}
}
int mangduong(int a[],int n,int b[],int &m)
{
//gan m=0
m=0;
//duyen mang a
for(int i=0;i<n;i++)
{
//neu a[i]>0 thi gan b[n]=a[i]
if(a[i]>0)
{
b[m]=a[i];
m++;
}
}
if(m==0)return -1;
else return 1;
}
int min_duong(int b[],int m)
{
int min=b[0];
for(int i=0;i<m;i++)
{
if(min>b[i])
min=b[i];
}
return min;
}
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// Itec.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "iostream"
using namespace std;
void nhap(int a[],int &n)
{
cout<<"Nhap so luong phan tu cua mang:";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Nhap a["<<i<<"]:";
cin>>a[i];
}
}
void xuat(int a[],int n)
{
cout<<"Xuat mang :";
for(int i=0;i<n;i++)
{
cout<<" "<<a[i];
}
}
int mangduong(int a[],int n,int b[],int &m)
{
//gan m=0
m=0;
//duyen mang a
for(int i=0;i<n;i++)
{
//neu a[i]>0 thi gan b[n]=a[i]
if(a[i]>0)
{
b[m]=a[i];
m++;
}
}
if(m==0)return -1;
else return 1;
}
int min_duong(int b[],int m)
{
int min=b[0];
for(int i=0;i<m;i++)
{
if(min>b[i])
min=b[i];
}
return min;
}
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|