Skip to content

Instantly share code, notes, and snippets.

@oscarmcm
Created November 17, 2014 01:06
Show Gist options
  • Save oscarmcm/04d76e2aa37d4b1fc1ff to your computer and use it in GitHub Desktop.
Save oscarmcm/04d76e2aa37d4b1fc1ff to your computer and use it in GitHub Desktop.
#include <iostream>
#include <conio.h>
#include <cmath>
#include <cstdlib>
#include <time.h>
#include <ctime>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv)
{
int num[3][3];
void randomize(void);
srand ( time(NULL) );
for (int i=0; i<=3; i++)
{
for (int j=0; j<=3; j++)
{
num[i][j]=rand()%91;
cout<<num[i][j]<<" ";
}
cout<<endl;
}
int contador;
contador=0;
for (int i=0; i<=3; i++)
{
for (int j=0; j<=3; j++)
{
if (num[i][j]%2==1)
{
contador=contador+1;
}
else
{}
}
cout<<endl;
}
cout<<"la cantidad de numeros impares en la matriz es: " <<contador<<endl;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment