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;
}

sat 21 @ 9 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 row=5;
const int col=7;
static const char zin[]="0123456789""abcdefghijklmnopqrstuvwxyz""!<>)(*&^%%$#@!";


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

    time_t t;
    srand (time(&t));
    char mat[row][col];
    int i,j;
    char arr[50];
    char taw[50];
    int b=0;
    for(i=0;i<row;i++)
    {
        for(j=0;j<col;j++)
        {
            mat[i][j] =zin[rand()%(sizeof(zin)-1)];
            //mat[i][j] =rand()% 200-100;

            cout<<setw(4)<<mat[i][j];
        }
        cout<<endl;
        cout<<endl;
    }
    cout<<endl; cout<<endl; cout<<endl;
    for(j=0;j<col;j++)
    {
        for(i=0;i<row;i++)
           
        {
            if( !(mat[i][j]>='a'&& mat[i][j]<='z') && !(mat[i][j]>='0' && mat[i][j]<='9'))
            {
                taw[b++]=mat[i][j];
            }

    }
    cout<<b<<endl;
    b=0;
    }

    /*
    for(i=0;i<b;i++)
    {
            cout<<setw(5)<<taw[i];
    }
    */
   
    getch();
    return 0;
}