Suma matricilor
Sum of matrix
#include <iostream>
using namespace std;
int i,j,n,a[10][10];
float b[10][10];
void citire()
★ {
| for(i=1;i<=n;i++)
| for(j=1;j<=n;j++)
|★ {
|| cout<<"a["<<i<<"]["<<j<<"]=";
|| cin>>a[i][j];
|★ }
|| cin>>a[i][j];
|★ }
★}
void matb()
★ {
| for(i=1;i<=n;i++)
| for(j=1;j<=n;j++)
| b[i][j]=(a[i][j]+a[j][i])/2;
★ }
| for(j=1;j<=n;j++)
| b[i][j]=(a[i][j]+a[j][i])/2;
★ }
void afisare()
★ {
★ {
| for(i=1;i<=n;i++)
|★ {
|★ {
|| for(j=1;j<=n;j++)
|| cout<<b[i][j];
|| cout<<"\n";
|| cout<<b[i][j];
|| cout<<"\n";
|★ }
★ }
int main()
★ {
★ {
| cout<<"Numarul de linii si coloane este=";cin>>n;
| citire();
| matb();
| afisare();
| citire();
| matb();
| afisare();
|
| return 0;
★ }
| return 0;
★ }
Niciun comentariu:
Trimiteți un comentariu