i think there is some problem in your these loops check it out
for(int mat=0;mat<3;mat++)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(mat==0) c[i][j]=0;
if(mat==1) mf[i][j]=0;
if(mat==2) res[i][j]=0;
for(k=0;k<3;k++)
{
if(mat==0)
c[i][j]+=r[i][k]*x[k][j];
if(mat==1)
{
x[0][2]=tx;
x[1][2]=ty;
mf[i][j]+=x[i][k]*c[k][j];
}
if(mat==2)
res[i][j]+=mf[i][k]*t[k][j];
}
cout<<res[i][j];
}
}
}
multiply your matrices one by one(use different loop for each multiplication) and run your program again.
OR
use this modified code:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
float x[3][3],y[3][3],z[3][3],p[3][3],q[3][3];
float angle,ptx,pty;
int i,j,k;
cout<<"Enter coordinates of triangle:";
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
cin>>y[j][i];
}
}
y[2][0]=1;
y[2][1]=1;
y[2][2]=1;
cout<<"Enter the point about:";
cin>>ptx>>pty;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i==j)
x[i][j]=1;
else
x[i][j]=0;
}
}
x[0][2]=-ptx;
x[1][2]=-pty;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
z[i][j]=0;
for(int k=0;k<3;k++)
{
z[i][j]+=x[i][k]*y[k][j];
}
}
}
cout<<"Enter angle of rotation:";
cin>>angle;
angle*=(3.14/180);
for(i=0;i<3;i++)
{ for(j=0;j<3;j++)
{
if(i==j)
x[i][j]=1;
else
x[i][j]=0;
}
}
x[0][0]=cos(angle);
x[0][1]=-sin(angle);
x[1][0]=sin(angle);
x[1][1]=cos(angle);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
p[i][j]=0;
for(int k=0;k<3;k++)
{
p[i][j]+=(x[i][k]*z[k][j]);
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i==j)
x[i][j]=1;
else
x[i][j]=0;
}
}
x[0][2]=ptx;
x[1][2]=pty;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
q[i][j]=0;
for(int k=0;k<3;k++)
{
q[i][j]+=(x[i][k]*p[k][j]);
}
}
}
clrscr();
line(y[0][0],y[1][0],y[0][1],y[1][1]);
line(y[0][0],y[1][0],y[0][2],y[1][2]);
line(y[0][1],y[1][1],y[0][2],y[1][2]);
line(q[0][0],q[1][0],q[0][1],q[1][1]);
line(q[0][0],q[1][0],q[0][2],q[1][2]);
line(q[0][1],q[1][1],q[0][2],q[1][2]);
getch();
}