Sunday, October 9, 2011

matrix

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include<stdlib.h>
#include <math.h>
#include <time.h>
#include<iomanip>;
using namespace std;
const int n=6;
const int m=7;
static const char arkar[]="0123456789""abcdefghijklmnopqrstuvwxyz";

int _tmain(int argc, _TCHAR* argv[])
{

time_t t;
srand (time(&t));
char mat[n][m],i,j;
cout<<"\n That is my character matrix \n" ;
int count_char=0;
int count_num=0;
int bb=0;

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
mat[i][j] =arkar[rand()%(sizeof(arkar)-1)];
cout<<setw(4)<<mat[i][j];
}
cout<<endl;
}

cout<<endl; cout<<endl; cout<<endl;
for(j=0;j<m;j++)
{
for(i=0;i<n;i++)

{
if( mat[i][j]>='a' && mat[i][j]<='z' )
count_char++;
if (mat[i][j]>='0' && mat[i][j]<='9')
count_num++;

}
bb++;
cout<< bb<<" column ==> char " << count_char <<" integer " << count_num<<endl;;
count_char=0;
count_num=0;
}


getch();
return 0;
}

No comments: