matrices

matrices

Este es mi código :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main(int argc, char *argv[]) {
	int suma,n,a[100][100],b[100][100],c[100][100];
	srand(time(0));
	cout<<"Defina de cuanto es la matriz: ";cin>>n;
	cout<<endl;
	cout<<"MATRIZ(1)"<<"\n";
	for(int x=0; x<n;x++){
		cout<<"[ ";

		for(int y=0; y<n; y++){
			a[x][y]=rand()%(60-30+1)+30;
			b[x][y]=rand()%(9-1+1)+1;
			cout<<" "<<a[x][y];
		}
		cout<<" ]"<<endl;
	}
	cout<<"MATRIZ(2)"<<"\n" ;
	for(int x=0; x<n;x++){
		cout<<"[";
		for(int y=0; y<n; y++){
			cout<<" "<<b[x][y];
		}
		cout<<" ]"<<endl;
	}
	cout<<"MATRIZ(3)"<<"\n";
	suma=0;
	for(int x=0; x<n;x++){
		cout<<"[";
		for(int y=0; y<n; y++){
			c[x][y]=a[x][y]*b[x][y];
			suma=a[x][y]+b[x][y];
			if( (x>0 && x<n-1 && y>0 && y<n-1))
			{
				cout<<" "<<suma;
			}
			else
			{
				cout<<" "<<c[x][y];
			}
		}
		cout<<" ]"<<endl;
	}
	return 0;
}

Jimenez

None

Reactions

0

0

1

0

Responsive image
Master

2

0

20-12-06 20:48

Hola! Podrias usar el cuadro de codigo en el editor para que podamos leer mejor tu codigo? Mira como usar el editor aqui https://thewhitecode.com/blog/4518 Para editar tu publicacion, ve a tu perfil en la parde de "posts"

Access hereTo be able to comment

TheWhiteCode.com is not the creator or owner of the images shown, references are: