Learning Visual Studio
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Ky thuat tinh toan

Go down

Ky thuat tinh toan Empty Ky thuat tinh toan

Post  Admin Wed Dec 17, 2008 8:16 am

void nhap(int a[][100],int &m,int &n)
{
cout<<"Nhap m:";//printf("Nhap n:");scanf("%d",m)
cin>>m;
cout<<endl<<"Nhap n:";//printf("Nhap n:");scanf("%d",n)
cin>>n;

for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
{
cout<<"Nhap a["<<i<<j<<"]=";
cin>>a[i][j];
}
}

void xuat(int a[][100],int m,int n)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)

cout<<a[i][j]<<" ";
cout<<endl;

}
}
int tong_duong(int a[][100],int m,int n)
{
int tong=0;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
if(a[i][j]>0)
tong+=a[i][j];

return tong;
}
int tich_le(int a[][100],int m,int n)
{
int tich=1;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
if(a[i][j]%2!=0)
tich*=a[i][j];

return tich;

}
//bai 322
void nhap_float(float a[][100],int &m,int &n)
{
cout<<"Nhap m:";//printf("Nhap n:");scanf("%f",m)
cin>>m;
cout<<endl<<"Nhap n:";//printf("Nhap n:");scanf("%f",n)
cin>>n;

for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
{
cout<<"Nhap a["<<i<<j<<"]=";
cin>>a[i][j];
}
}
void xuat_float(float a[][100],int m,int n)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)

cout<<a[i][j]<<" ";
cout<<endl;

}
}
void tong_hang(float a[][100],int m,int n)
{
for(int i=0;i<m;i++)
{
float tong=0;
for(int j=0;j<n;j++)
tong+=a[i][j];
cout<<"tong hang thu "<<i<<" la "<<tong<<endl;
}

}
void tong_duong_hang(float a[][100],int m,int n)//324
{
for(int i=0;i<m;i++)
{
float tong=0;
for(int j=0;j<n;j++)
if(a[i][j]>0)
tong+=a[i][j];
cout<<"tong duong hang thu "<<i<<" la "<<tong<<endl;
}

}
void tong_duong_cot(float a[][100],int m,int n)//323
{
for(int i=0;i<n;i++)
{
float tong=0;
for(int j=0;j<m;j++)
if(a[j][i]>0)
tong+=a[j][i];
cout<<"tong duong cot thu "<<i<<" la "<<tong<<endl;
}

}
//bai 325
void tong_chan_cot(int a[][100],int m,int n)//325
{
for(int i=0;i<n;i++)
{
float tong=0;
for(int j=0;j<m;j++)
if(a[j][i]%2==0)
tong+=a[j][i];
cout<<"tong cac so chan cot thu "<<i<<" la "<<tong<<endl;
}

}
//bai 326 tinh trung binh cong cac so duong
float trung_binh_duong(float a[][100],int m,int n)
{
float tong=0;
int dem=0;

for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
if(a[i][j]>0)
{
tong+=a[j][i];
dem++;
}


return tong/dem;
}

//bai 327
int tong_bien(int a[][100],int m, int n)
{
int sum=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
if(i==0||i==m-1)
sum+=a[i][j];
if(i>0&&i<m-1)
{
sum+=a[i][0];
sum+=a[i][n-1];
}
}
return sum;
}

Admin
Admin

Posts : 4
Join date : 2008-12-08

https://tranvantam2009.board-directory.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum