Image may be NSFW.
Clik here to view.
This programme is designed for circular matrix representation in which matrix inputted by user.
#include<stdio.h> #include<math.h> void main() { char ch; do { int a[30][30],y=0 , i , j , k ,m,n,v=1,temp ; int x=1, b=1; clrscr(); printf("Welcome to CodingTalks :::nn"); printf("Please Enter value of n ... Here n represent nxn matrics nn"); scanf("%d",&n); printf("nnSo u select %dx%d matrix",n,n); m=n; do { for(i=x;i<=n;i++) { for(j=b;j<=n;j++) { if(i==x) { for(k=i;k<=n;k++) { a[i][k]=v; v++; } j=n; } if(j==n) { for(k=i+1;k<=n;k++) { a[k][j]=v; v++; } i=n; } if(i==n) { v--; for(k=n;k>=x;k--) { a[i][k]=v; v++; } v--; for(i=n;i>x;i--) { a[i][x]=v; v++; } } i=n; j=n; } } y++; x++; b++; n--; }while(y<m); printf("nn"); printf("So finally Output Matrix is ::: nn"); for(i=1;i<=m;i++) { printf("n"); for(j=1;j<=m;j++) { printf("%dt",a[i][j]); } } printf("nnnIf you want to make another matrix then press Y nn "); scanf("%s",&ch); printf("Press Enter to continue n"); printf(". . . "); getch(); }while(ch=='y'||ch=="Y"); printf(" Thanks for using my program ::.. viv_4u ..:: nn"); getch(); printf(" n Exit... "); getch(); }
Download executable file that program.
The post Circular Matrix in C++ appeared first on CodingTalks.