Está en la página 1de 15

Dado una matriz de 3 x 3, llene toda la matriz de números pares, excepto la diagonal principal con número

1. Al final imprima la matriz y la suma de toda la matriz.


#include <iostream>
using namespace std;
int main() {
int matriz[3][3];
int num=0, sum=0;
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
if (i==j) {
matriz[i][j]=1;
} else {
matriz[i][j]=num;
num+=2;
}
}
}
cout << "La matriz es: " << endl;
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
cout << matriz[i][j] << "\t";
sum += matriz[i][j];
}
cout << endl;
}
cout << "La suma es: " << sum;
return 0;
}
LUIS ERNESTO MENDOZA AYMARA11:13
ya termine profesora
GUILLERMO CESAR URIBE MEJIA11:15
termine :(
LUIS ERNESTO MENDOZA AYMARA11:16
int main(){
int x[3][3],suma;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(i==j){
x[i][j]=1;
}
else{
cout<<"digite el numero par "<<endl;cin>>x[i][j];
cout<<endl;
if(x[i][j]%2!=0){
cout<<endl<<"el numero introducido no es par, vuelva a
escribir...."<<endl;
j--;
}
}
suma=suma+x[i][j];
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<x[i][j]<<"\t";
}
cout<<endl;
}
cout<<endl;
cout<<"la suma total de la matriz es: "<<suma;
return 0;
}
GABRIEL ISAAC CUBA GARCIA11:16
terminé
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
int A[3][3],num,sumaM=0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<"Ingrese el numero par en la matriz:";
cin>>num;
if(i==j){
A[i][j]=1;
}
else{
if(num%2==0){
A[i][j]=num;
sumaM+=num;
}
else{
cout<<"Error Ingrese un numero par!";
j--;
}
}
}
}
cout<<endl;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<A[j][i]<<"\t";
}
cout<<endl;
}
cout
GABRIEL ISAAC CUBA GARCIA11:17
cout<<"La suma de la matriz es: "<<sumaM;
return 0;
getch();
}
ALVARO RIMBAUD POMA ALEGRE11:20
acabé profesora
#include<iostream>
using namespace std;

int main(){
int a[3][3], suma=0;

for(int i=0; i<3; i++){


for( int j=0; j<3; j++){
cout<<"Pos: "<<i<<", "<<j<<". Digite un numero par numero: ";
cin>>a[i][j];
if(a[i][j]%2!=0){
cout<<"\nDigite el numero otra vez."<<endl;
j--;
}
}
cout<<endl;
}

for(int i=0; i<3; i++){


for( int j=0; j<3; j++){
if(i==j){
a[i][j]=1;
}
cout<<a[i][j]<<"\t";
suma+=a[i][j];
}
cout<<endl;
}

cout<<"\nLa suma de los numero


MELVIN LUIGI HUARICACHA MASIAS11:20
acabe profesora :

#include <iostream>
using namespace std;
int main(){
int x[3][3];
int num,sum;
for (int i=0;i<3;i++){
sum=0;
for(int j=0;j<3;j++){
cout<<"Ingrese un valor par para llenar la matriz "<<endl;
cin>>x[i][j];
sum+=x[i][j];
if(i==j){
x[i][j]=1;
} else{
if(num%2==0){
x[i][j]=num;
sum+=num;
}
else{
cout<<"Ingrese un numero par!!!";
}
}
}
}
cout<<"matriz: "<<endl;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<
CARLOS MANUEL SOSA LUPUCHE11:27
termine
#include<iostream>
using namespace std;
int main (){
int matriz[3][3];
int num=0,suma=0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<"Ingrese la fila "<<j<<" y columna "<< i <<":"<<endl;
cin>>matriz[i][j];
if(i==j){
matriz[i][j]=1;
}
else if(matriz[i][j]%2==0)
{
num=matriz[i][j];
suma=suma+num;
}
else {
cout<<"Ingrese un numero par"<<endl;
j=j-1;
}
}
}
cout<<"La matriz es:"<<endl;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<matriz[i][j]<<"\t";
}
cout<<endl;
}
cout<<"la suma es:"<<suma+3<<endl;
return 0;
}
ALONSO ANDRE MANRIQUE ARIZA11:57
26?
ALONSO ANDRE MANRIQUE ARIZA12:03
el j=0; deberia ir en la linea 25 creo
MARIA ELENA RUIZ RIVERA12:09
5. Dado la siguiente matriz, cuente cuantos números son primos. Luego imprima la matriz y la cantidad
de primos.

A[3][3]={{12,6,20}, {11,13,1},{17,5,28}}
JOSE LUIS VERGARA PACHAS12:15
terminé
#include <iostream>
using namespace std;
int main() {
int contPrimo=0;
bool esPrimo;
int A[3][3]={{12,6,20}, {11,13,1},{17,5,28}};
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
cout << A[i][j] << "\t";
esPrimo=true;
for (int k=2; k<A[i][j];k++) {
if (A[i][j]%k==0) {
esPrimo=false;
break;
}
}
if (A[i][j]==1) {
esPrimo=false;
}
if (esPrimo) {
contPrimo++;
}
}
cout << endl;
}
cout << "La cantidad es primos es: " << contPrimo;
return 0;
}
GABRIEL ISAAC CUBA GARCIA12:16
terminé
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
int A[3][3]={{12,6,20}, {11,13,1},{17,5,28}},cpr=0,contpr=0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cpr=0;
if(A[i][j]%2!=0){
for(int x=1;x<A[i][j];x++){
if(A[i][j]%x==0){
cpr++;
}
}
if(cpr==1){
contpr++;
}
}
}
}
cout<<"La matriz es: ";
cout<<endl;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<A[i][j]<<"\t";
}
cout<<endl;
}
cout<<"La cantidad de nume
GABRIEL ISAAC CUBA GARCIA12:18
ros primos en la matriz es: "<<contpr;
return 0;
getch();
}
LUIS ERNESTO MENDOZA AYMARA12:20
termine profesora
CARLOS MANUEL SOSA LUPUCHE12:22
termine
ASHLY CHAVEZ MARON12:23
termine
MARIA ELENA RUIZ RIVERA12:53
Una mecánica recibe N caros de diferentes placas, hasta que llegue un vehículo de placa 99679, termina la
recepción. Al final imprima cuantos carros recibió en el día.
Tú12:54
comprendo profesora
JOSE LUIS VERGARA PACHAS12:56
terminé
SERGIO ANDRE MARCOS JUAREZ12:56
terminé profesora
JOSE LUIS VERGARA PACHAS12:56
#include <iostream>
using namespace std;
int main() {
int placa;
int cont=0;
do {
cout << "Ingrese el numero de la placa: ";
cin >> placa;
cont++;
} while (placa!=99679);
cout << "El numero de carros es: " << cont;
return 0;
}
LUIS ERNESTO MENDOZA AYMARA12:56
termine profesora
ASHLY CHAVEZ MARON12:57
termine
CARLOS MANUEL SOSA LUPUCHE12:57
termine
GABRIEL ISAAC CUBA GARCIA12:58
terminé
SERGIO ANDRE MARCOS JUAREZ12:58
#include<iostream>
using namespace std;
int main(){
int placa, carros=0;
do{
cin>>placa;
carros++;
}while(placa!=99679);
cout<<"el numero de carros es: "<<carros;
}
ALVARO RIMBAUD POMA ALEGRE12:59
terminé
EVA MARIA FLORISA BAYES ENRIQUEZ13:01
ya me salió
ALONSO ANDRE MANRIQUE ARIZA13:02
quita las lineas 8 y 9
ALONSO ANDRE MANRIQUE ARIZA13:05
con do while si no iria
MARIA ELENA RUIZ RIVERA13:10
1. Dado la siguiente matriz N, cuente cuanto son positivos, negativos y nulos. Al final imprimir la matriz
y la cantidad de positivos, negativos y nulos.

{{12,-13,14,-5},{27,0,11,-17},{2,9,3,-3}}
JOSE LUIS VERGARA PACHAS13:13
terminé
SERGIO ANDRE MARCOS JUAREZ13:15
terminé profesora
CARLOS MANUEL SOSA LUPUCHE13:16
termine
EVA MARIA FLORISA BAYES ENRIQUEZ13:16
terminé
SERGIO ANDRE MARCOS JUAREZ13:22
/*Una mecánica recibe N caros de diferentes placas, hasta que
llegue un vehículo de placa 99679, termina la recepción. Al
final imprima cuantos carros recibió en el día.*/
#include<iostream>
using namespace std;
int main(){
int placa, carros=0;
do{
cin>>placa;
carros++;
}while(placa!=99679);
cout<<"el numero de carros es: "<<carros;
}
MILAGROS GUADALUPE SIANCAS RAMIREZ13:22
/*Una mecánica recibe N caros de diferentes placas,
hasta que llegue un vehículo de placa 99679, termina la recepción.
Al final imprima cuantos carros recibió en el día.*/
#include<iostream>
using namespace std;
int main(){
int N, placa, contador;
cout<<"Ingrese la placa del vehiculo: ";
cin>>placa;
while(placa!=99679){
cout<<"Ingrese la placa del vehiculo: ";
cin>>placa;
contador++;
}
cout<<"La cantidad de carros que recibio es: "<<contador;
return 0;
}
MARIA ELENA RUIZ RIVERA13:27
2) Al cerrar un expendio de naranjas, 15 clientes que aun no han pagado recibirán un 15% de descuento si
compran más de 10 kilos. Determinar cuanto pagara cada cliente y cuanto percibirá la tienda por esas
compras.
JOSE LUIS VERGARA PACHAS13:35
terminé
YAGO DEREM SOLIS GUERRERO13:35
termine
JOSE LUIS VERGARA PACHAS13:35
#include <iostream>
using namespace std;
int main() {
int kilos, i;
float precio, precioNeto, sumT=0;
cout << "Ingresar el precio del kilo de naranja: ";
cin >> precio;
i = 1;
while (i<=15) {
cout << i << ". Ingresar la cantidad de kilos de naranjas que compró: ";
cin >> kilos;
precioNeto = kilos * precio;
if (kilos > 10) {
precioNeto = precioNeto - precioNeto * 15/100.0;
}
cout << i << ". Pagara: " << precioNeto << endl;
sumT += precioNeto;
i++;
}
#include <iostream>
using namespace std;
int main() {
int kilos, i;
float precio, precioNeto, sumT=0;
cout << "Ingresar el precio del kilo de naranja: ";
cin >> precio;
i = 1;
while (i<=15) {
cout << i << ". Ingresar la cantidad de kilos de naranjas que compró: ";
cin >> kilos;
precioNeto = kilos * precio;
if (kilos > 10) {
precioNeto = precioNeto - precioNeto * 15/100.0;
}
cout << i << ". Pagara: " << precioNeto << endl;
sumT += precioNeto;
i++;
}
cout << "La tienda recibira: " << sumT;

return 0;
}
EVA MARIA FLORISA BAYES ENRIQUEZ13:39
ya terminé
GABRIEL ISAAC CUBA GARCIA13:41
terminé
phx-zazh-msr

También podría gustarte