Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

5/1/2022

Assignment ON:
C++ programs
Submitted to:
Dr. Fayyaz Hussain
Submitted by:
Ghulam Abbas
Roll No.
BSM-P-19-09
Class:
Bs-Physics (Morning)5th Semester

Department of
physics
Program# 01

*//multiplication of matrices//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main ()
{
Clrscr ();
int I , j, k ,a[10][10],b[10][10],c[10][10]={0};
int r1, c1, r2, c2;
cout<<"enter 1st matrix rows and columns=";
cin>>r1>>c1;
cout<<"enter 2nd matrix rows and columns=";
cin>>r2>>c2;
if(c1==r2)
{
cout<<"multiplictaion is possible:"<<endl;
if(c1!=r2)
cout<<"multiplication is not possible:"<<endl;
}
for(i=0;i<r1;i++)
{
cout<<endl;
cout<<"enter elements of matrix a=";
for(j=0;j<c1;j++)
cin>>a[i][j];
}
for(i=0;i<r2;i++)
{
cout<<endl;
cout<<"enter elements of matrix b=";
for(j=0;j<c2;j++)
cin>>b[i][j];
}
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
for(k=0;k<c1;k++)
{
c[i][j]=c[i][j] + a[i][k]*b[k][j];
}}}
cout<<endl<<"multiplication of matrices="<<endl;
for (i=0; i<r1; i++)
{
for(j=0;j<c1;j++)
cout<<c[i][j]<<" ";
}
cout<<endl;
}
getch();
}

Output
enter 1st matrix rows and columns=3 3
enter 2nd matrix rows and columns=3 2
multiplication is possible:
enter elements of matrix a=1 2 3 4 5 6 7 8 9
enter elements of matrix b= 1 2 3 4 5 6
multiplication of matrices=

22 28
49 64
76 100

Program#02

*//Addition of matrices//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,r1,c1,r2,c2,a[20][20],b[20][20],c[20][20];
cout<<"enter rows and columns of 1st matrix=";
cin>>r1>>c1;
cout<<"enter rows and columns of 2nd matrix=";
cin>>r2>>c2;
if((r1!=r2)&&(c1!=c2))
{
cout<<"addition is not possible";
}
for(i=0;i<r1;i++)
{
for(j=o;j<c1;j++)
}
cout<<"enter elements of 1st matrix=";
cin>>a[i][j];
for(i=0;i<r2;i++)
{
cout<<endl;
for(j=0;j<c2;j++)
}
cout<<"enter elements of 2nd matrix=";
cin>>b[i][j];
for(i=0;i<r1;i++)
{
cout<<endl;
for(j=0;j<c1;j++)
cout<<endl;
{
c[i][j]=a[i][j]+b[i][j];
cout<<"addition of matrices="<<endl;
for(i=0;i<r1;i++)
{
cout<<endl;
for(j=0;j<c1;j++)
}}}
cout<<c[i][j]<<endl;
getch ();
}

Output
enter rows and columns of 1st matrix=2 2
enter rows and columns of 2nd matrix=2 2
enter elements of 1st matrix= 1 2 3 4
enter elements of 2nd matrix= 1 2 3 4
addition of matrices=
2 4
6 8

Program#03

*//Subtraction of matrices//*

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,r1,c1,r2,c2,a[20][20],b[20][20],c[20][20];
cout<<"enter rows and columns of 1st matrix=";
cin>>r1>>c1;
cout<<"enter rows and columns of 2nd matrix=";
cin>>r2>>c2;
if((r1!=r2)&&(c1!=c2))
{
cout<<"subtraction is not possible";
}
for(i=0;i<r1;i++)
{
for(j=o;j<c1;j++)
}
cout<<"enter elements of 1st matrix=";
cin>>a[i][j];
for(i=0;i<r2;i++)
{
cout<<endl;
for(j=0;j<c2;j++)
}
cout<<"enter elements of 2nd matrix=";
cin>>b[i][j];
for(i=0;i<r1;i++)
{
cout<<endl;
for(j=0;j<c1;j++)
cout<<endl;
{
c[i][j]=a[i][j]+b[i][j];
cout<<"addition of matrices="<<endl;
for(i=0;i<r1;i++)
{
cout<<endl;
for(j=0;j<c1;j++)
}}}
cout<<c[i][j]<<endl;
getch ();
}

Output

enter rows and columns of 1st matrix=2 2


enter rows and columns of 2nd matrix=2 2
enter elements of 1st matrix= 4 3 7 5
enter elements of 2nd matrix= 1 2 3 4
addition of matrices=
3 1
4 1

Program#04

*//Inverse of matrix//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,k,a[3][3],b[3][3];
double c[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"enter the element"<<i+1<<":"<<j+1<<"=";
cin>>a[i][j];
}
}
b[0][0]=a[1][1]*a[2][2]-a[1][2]*a[2][1];
b[0][1]=-1*(a[1][0]*a[2][2]-a[1][2]*a[2][0]);
b[0][2]=a[1][0]*a[2][1]-a[1][1]*a[2][0];
b[1][0]=-1*(a[0][1]*a[2][2]-a[0][2]*a[2][1]);
b[1][1]=a[0][0]*a[2][2]-a[0][2]*a[2][0];
b[1][2]=-1*(a[0][0]*a[2][1]-a[0][1]*a[2][0]);
b [2][0] =a[0][1]*a[1][2]-a[0][2]*a[1][1];
b[2][1]=-1*(a[0][0]*a[1][2]-a[0][2]*a[1][0]);
b[2][2]=a[0][0]*a[1][1]-a[0][1]*a[1][0];
long int det=a[0][0]*(a[1][1]*a[2][2]-a[2][1]*a[1][2])-
a[0][1]*(a[1][0]*a[2][2]-a[2][0]*a[1][2])+a[0][2]*(a[1][0]*a[2][1]-
a[2][0]*a[1][1]);
//for adjoint
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
c[i][j]=b[j][i];
}
//for inverse
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
c[i][j]=c[i][j]/det;
}
if(det!=0)
{
cout<<"inverse of matrix is:";
//for displaying output
for(i=0;i<3;i++)
{
cout<<endl<<endl<<endl;
for(j=0;j<3;j++)
cout<<c[i][j]<<" ";
}}
else
cout<<"inverse is not possible";
getch();
}
Output

enter the element 1:1=1


enter the element 1:2=2
enter the element 1:3=3
enter the element 2:1=0
enter the element2:2=1
enter the element2:3=4
enter the element3:1=5
enter the element3:2=6
enter the element3:3=0
inverse of matrix is:
-24 18 5
20 -15 4
-5 4 1

Program#05

*//Newton method//*

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#define f(x) (x*x*x-2*x-5)
#define F(x) (3*x*x-2)
float main()
{
clrscr();
int n,i=0;
float a,b,t,diff,x0,x;
cout<<"enter the initial value=";
cin>>a;
cout<<"enter the final value=";
cin>>b;
cout<<"enter the no. of iterations=";
cin>>n;
cout<<"enter the tolerance=";
cin>>t;
if(f(a)*f(b)>0)
{
cout<<"root does not lie between"<<a<<"and"<<b<<endl;
cout<<"please enter another interval=";
}
if(f(a)>f(b))
x0=a;
else
x0=b;
do
{
x=x0-(f(x0)/F(x0));
i++;
diff=fabs((x-x0)/2.0);
x0=x;
{
cout<<"Root="<<x<<endl;
}}
while((i<n)&&(f(x)!=0)&&(diff>t));
getch();
return(x);
}

Output

enter the initial value=2


enter the final value=3
enter the no. of iterations=20
enter the tolerance=0.00005
Root=2.094552
Program#06

*//Simpson method//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define f(x) (x*x)

void main()
{
clrscr();
int interval,a,b,x,k;
float sum,h,xk,area;
cout<<"enter the initial vlue=";
cin>>a;
cout<<"enter the final value=";
cin>>b;
cout<<"enter the interval =";
cin>>interval;
h=(b-a)/interval;
sum=f(a)+f(b);
for(k=1;k<interval;k++)
{
xk = a+k*h;
if(k%2==0)
sum=sum+2*f(xk);
else
sum=sum+4*f(xk);
}
area=sum*h/3;
{
cout<<"Answer="<<area<<endl;
}
getch();
}

Output

enter the initial value=0


enter the final value=3
enter the interval=3
Answer=7
Program#07

*//Trapezoidal method//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define f(x) (x*x)

void main()
{
clrscr();
int interval,a,b,x,k;
float sum,h,xk,area;
cout<<"enter the initial vlue=";
cin>>a;
cout<<"enter the final value=";
cin>>b;
cout<<"enter the interval =";
cin>>interval;
h=(b-a)/interval;
sum=f(a)+f(b);
for(k=1;k<interval;k++)
{
xk = a+k*h;
sum=sum+2*f(xk);
}
area=sum*h/2;
{
cout<<"Answer="<<area<<endl;
}
getch();
}
Output

enter the initial value=0


enter the final value=3
enter the interval=3
Answer=9.5

Program#08

*//Bisection method//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define f(x) (sin(x)-5*x+2)
float main()
{
clrscr();
int n,i=0;
float a,b,t,c,interval;
cout<<"enter initial value=";
cin>>a;
cout<<"enter final value=";
cin>>b;
cout<<"enter the no. of iterations=";
cin>>n;
cout<<"enter tolerance=";
cin>>t;
if(f(a)*f(b)<0)
do
{
c=(a+b)/2.0;
if(f(a)*f(c)<0)
b=c;
else
a=c;
i++;
interval=fabs((b-a)/2.0);
cout<<"Answer="<<c<<endl;
}
while((i<n)&&(f(c)!=0)&&(interval>t));
getch();
return(c);
}

Output

enter the initial value=0.4


enter the final value=0.6
enter the no. of iterations=20
enter tolerance=0.0005
Answer=0.495008

Program#09

*//false position method//*


#include<iostream.h>
#include<conio.h>
#include<math.h>
#define f(x) (sin(x)-5*x+2)
float main()
{
clrscr();
int n,i=0;
float a,b,t,c,interval;
cout<<"enter initial value=";
cin>>a;
cout<<"enter final value=";
cin>>b;
cout<<"enter number of itrations=";
cin>>n;
cout<<"enter tolerance=";
cin>>t;
if(f(a)*f(b)<0)
do
{
c=a-f(a)*(b-a)/(f(b)-f(a));
if(f(a)*f(c)<0)
b=c;
else
a=c;
i++;
interval=fabs((b-a)/2.0);
{
cout<<"Answer="<<c<<endl;
}}
while((i<n)&&(f(c)!=0)&&(interval>t));
getch();
return(c);
}

Output
enter the initial value=0.4
enter the final value=0.6
enter the no. of iterations=20
enter tolerance=0.0005
Answer=0.495008

Program#10
*//secant method//*
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define f(x) (sin(x)-5*x+2)
float main()
{
clrscr();
int n,i=0;
float a,b,t,c,interval;
cout<<"enter initial value=";
cin>>a;
cout<<"enter final value=";
cin>>b;
cout<<"enter number of itrations=";
cin>>n;
cout<<"enter tolerance=";
cin>>t;
do
{
c=a-f(a)*(b-a)/(f(b)-f(a));
i++;
interval=fabs((b-a)/2.0);
a=b;
b=c;
{
cout<<"Answer="<<c<<endl;
}}
while((i<n)&&(f(c)!=0)&&(interval>t));
getch();
return(c);
}

Output

enter the initial value=0.4


enter the final value=0.6
enter the no. of iterations=20
enter tolerance=0.0005
Answer=0.495008

Program#11

*//Jacobi method//
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,m,n,itt;
float x[10],a[10][10],b[10],c[10];
cout<<"enter no. of equations to be solved=";
cin>>n;
cout<<"enter no. of iterations=";
cin>>itt;
cout<<"enter the constants terms of equations=";
for(i=0;i<n;i++)
{
cin>>b[i];
}
cout<<"enter the coefficients of equations=";
for(i=0;i<n;i++)
{
x[i]=0;
for(j=0;j<n;j++)
cin>>a[i][j];
}
m=1;
line:
for(i=0;i<n;i++)
{
c[i]=b[i];
for(j=0;j<n;j++)
{
if(i!=j)
{
c[i]=c[i]-a[i][j]*x[j];
}}}
for(i=0;i<n;i++)
{
x[i]=c[i]/a[i][i];
}
m++;
if(m<=itt)
{
goto line;
}
else
{
cout<<"the solution of equations is:"<<endl;
for(i=0;i<n;i++)
cout<<"\n""x("<<i<<")="<<x[i]<<endl;
}
getch();
}

Output

enter no. of equations to be solved=3


enter no. of iterations=7
enter constants terms of equations= 85 72 110
enter the co-efficient of equations=27 6 -1 6 15 2 1 1 54
x (0) =2.426
x (1) =3.574
x (2) =1.926

Program#12

*//Gauss Elimination Method//


#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,k,n;
float a[10][10],b,x[10];
cout<<"enter no. of simultaneous equations=";
cin>>n;
cout<<"enter the elements of augmented matrix:"<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=(n+1);j++)
{
cout<<"A["<<i<<"."<<j<<"]=";
cin>>a[i][j];
}}
for(i=1;i<=(n-1);i++)
{
if(a[i][j]==0)
{
cout<<"Mathematical error!"<<endl;
}
for(j=i+1;j<=n;j++)
{
b=a[j][i]/a[i][i];
for(k=1;k<=(n+1);k++)
{
a[j][k]=a[j][k]-b*a[i][k];
}
}}
x[n]=a[n][n+1]/a[n][n];
for(i=n-1;i>=1;i--)
{
x[i]=a[i][n+1];
for(j=i+1;j<=n;j++)
{
x[i]=x[i]-a[i][j]*x[j];
}
x[i]=x[i]/a[i][i];
}
cout<<"after gauss elimination method matrix is="<<endl;
//Echilon form
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}}
cout<<"the solution is="<<endl;
//for displaying solution
for(i=1;i<=n;i++)
{
cout<<"x"<<i<<"="<<x[i]<<endl;
}
getch();
}

Output

enter no. of simultaneous equations=3


enter the elements of augmented matrix=
[1.1] =1
[1.2] =1
[1.3] =1
[1.4] =3
[2.1] =1
[2.2] =2
[2.3] =3
[2.4] =0
[3.1] =1
[3.2] =3
[3.3] =2
[3.4] =3
after gauss elimination method matrix is=
1 1 1
0 2 4
0 0 -3
the solution is=
x1=4
x2=1
x3= -2
Program#13
*//FCC crystal //*
#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,n;
cout<<"enter the value";
cin>>n;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
for(k=0;k<=n;k++)
{
cout<<i<<j<<k<<endl;
if(i>0&&j>0&&k>0)
{
cout<<((i+i-1)*0.5)<<"\t"<<((j+j-1)*0.5)<<"\t"<<((k+k-
1)*0)<<"\t"<<endl;
cout<<((i+i-1)*0.5)<<"\t"<<((j+j-1)*0)<<"\t"<<((k+k-
1)*0.5)<<"\t"<<endl;
cout<<((i+i-1)*0)<<"\t"<<((j+j-1)*0.5)<<"\t"<<((k+k-
1)*0.5)<<"\t"<<endl;
cout<<((i+i-1)*0.5)<<"\t"<<((j+j-1)*0.5)<<"\t"<<((k+k-
1)*1)<<"\t"<<endl;
cout<<((i+i-1)*0.5)<<"\t"<<((j+j-1)*1)<<"\t"<<((k+k-
1)*0.5)<<"\t"<<endl;
cout<<((i+i-1)*1)<<"\t"<<((j+j-1)*0.5)<<"\t"<<((k+k-
1)*0.5)<<"\t"<<endl;
}
}
getch();
}

Output

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
0.5 0.5 0
0.5 0 0.5
0 0.5 0.5
0.5 0.5 1
0.5 1 0.5
1 0.5 0.5

Program#14

*//Alloy 70% Ag and 30% Cu//*


#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,n;
float cu,ag;
cu=3.65;
ag=4.09;
cout<<"enter the number";
cin>>n;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
for(k=0;k<=n;k++)
{
cout<<i*ag<<"\t\t"<<j*ag<<"\t\t"<<k*ag<<"\t\t"<<endl;
if(i>0&&j>0&&k>0)
{
cout<<((i+i-1)*0)*ag<<"\t\t"<<((j+j-
1)*0.5)*ag<<"\t\t"<<((k+k1)*0.5)*ag<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*ag<<"\t\t"<<((j+j-
1)*0)*ag<<"\t\t"<<((k+k1)*0.5)*ag<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-
1)*0.5)*cu<<"\t\t"<<((k+k1)*0)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*1)*cu<<"\t\t"<<((j+j-
1)*0.5)*cu<<"\t\t"<<((k+k1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-
1)*1)*cu<<"\t\t"<<((k+k1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-
1)*0.5)*cu<<"\t\t"<<((k+k1)*1)*cu<<"\t\t"<<endl;
}
}
getch();
}

Output
enter the number=1
0 0 0
0 0 4.09
0 4.09 0
0 4.09 4.09
4.09 0 0
4.09 0 4.09
4.09 4.09 0
4.09 4.09 4.09
0 2.045 2.045
2.045 0 2.045
1.825 1.825 0
3.65 1.825 1.825
1.825 3.65 1.825
1.825 1.825 3.65

Program#15

*//Alloy 60% Ag and 40% Cu//*


#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,n;
float cu,ag;
cu=3.65;
ag=4.09;
cout<<"enter the number";
cin>>n;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
for(k=0;k<=n;k++)
{
cout<<i*ag<<"\t\t"<<j*ag<<"\t\t"<<k*ag<<"\t\t"<<endl;
if(i>0)&&j>0&&k>0)
{
cout<<((i+i-1)*0)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*0)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*0)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*1)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*1)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*1)*cu<<"\t\t"<<endl;
}
}
getch();
}

Output
Enter the number=1
0 0 0
0 0 4.09
0 4.09 0
0 4.09 4.09
4.09 0 0
4.09 0 4.09
4.09 4.09 0
4.09 4.09 4.09
0 1.825 1.825
1.825 0 1.825
1.825 1.825 0
3.65 1.825 1.825
1.825 3.65 1.825
1.825 1.825 3.65
Program#16

*//Alloy 50% Au and 50 % cu//*


#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,n;
float cu,ag;
cu=3.65;
ag=4.09;
cout<<"enter the mumber";
cin>>n;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
for(k=0;k<=n;k++)
{
if((i==0)&&(j==0)&&(k==1))
cout<<i*cu<<"\t\t"<<j*cu<<"\t\t"<<k*cu<<"\t\t"<<endl;
else
cout<<i*ag<<"\t\t"<<j*ag<<"\t\t"<<k*ag<<"\t\t"<<endl;
if(i>0&&j>0&&k>0)
{
cout<<((i+i-1)*0)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*0)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*0)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*1)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*1)*cu<<"\t\t"<<((k+k-
1)*0.5)*cu<<"\t\t"<<endl;
cout<<((i+i-1)*0.5)*cu<<"\t\t"<<((j+j-1)*0.5)*cu<<"\t\t"<<((k+k-
1)*1)*cu<<"\t\t"<<endl;
}
}
getch();
}

Output
enter the number=1
0 0 0
0 0 3.65
0 4.09 0
0 4.09 4.09
4.09 0 0
4.09 0 4.09
4.09 4.09 0
4.09 4.09 4.09
0 1.825 1.825
1.825 0 1.825
1.825 1.825 0
3.65 1.825 1.825
1.825 3.65 1.825
1.825 1.825 3.65
Program#17

HCP (Hexagonal Closed Packing)


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i,j,k;
cout<<"enter the number";
cin>>n;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
for(k=0;k<=(n+1);k++)
if(k!=1)
{
cout<<"cout<<i<<" "<<j<<" "<<k<<endl;
if(i!=0&&j!=0)
cout<<-i<<-j<<k<<endl;
if(i>0&&j>0&&k>0)
{
cout<<((i+i-1)*0.5)<<((j+j-1)*0.5)<<((k+k-3)*1)<<endl;
cout<<((i+i-1)*0)<<((j+j-1)*-0.5)<<((k+k-3)*1)<<endl;
cout<<((i+i-1)*-0.5)<<((j+j-1)*0)<<((k+k-3)*1)<<endl;
}}
getch();
}
Output
00 0
00 2
1 0 0
-1 0 0
1 0 2
-1 0 2
0 1 2
0 -1 2
1 1 2
-1 -1 2
0 1 0
0 -1 0
1 1 0
-1 -1 0
0.5 0.5 1
0 -0.5 1
-0.5 0 1

You might also like