1 Swallow Does Not Make a Summer
// transpose for the sparse matrix void main() { clrscr(); int a[10][10],b[10][10]; int m,n,p,q,t,col; int i,j; printf("enter the no of row and columns :\n"); scanf("%d %d",&m,&n); // assigning the value of matrix for(i=1;i<=m;i++) { for(j=1;j<=n;j++) { printf("a[%d][%d]= ",i,j); scanf("%d",&a[i][j]); } } printf("\n\n"); //displaying the matrix printf("\n\nThe matrix is :\n\n"); for(i=1;i<=m;i++) { for(j=1;j<=n;j++) { printf("%d\t",a[i][j]); } printf("\n"); } t=0; printf("\n\nthe non zero value matrix are :\n\n"); for(i=1;i<=m;i++) { for(j=1;j<=n;j++) { // accepting only non zero value if(a[i][j]!=0) { t=t+1; b[t][1]=i; b[t][2]=j; b[t][3]=a[i][j]; } } } printf("a[0 %d %d %d\n",m,n,t); for(i=1;i<=t;i++) { printf("a[%d %d %d %d\n",i,b[i][1],b[i][2],b[i][3]); } a[0][1]=n; a[0][2]=m; a[0][3]=t; int s[10],u[10]; if(t>0) { for(i=1;i<=n;i++) { s[i]=0; } for(i=1;i<=t;i++) { s[b[i][2]]=s[b[i][2]]+1; } u[1]=1; for(i=2;i<=n;i++) { u[i]=u[i-1]+s[i-1]; } for(i=1;i<=t;i++) { j=u[b[i][2]]; a[j][1]=b[i][2]; a[j][2]=b[i][1]; a[j][3]=b[i][3]; u[b[i][2]]=j+1; } } printf("\n\n the fast transpose matrix \n\n"); printf("a[0 %d %d %d\n",n,m,t); for(i=1;i<=t;i++) { printf("a[%d %d %d %d\n",i,a[i][1],a[i][2],a[i][3]); } getch(); }
Here is a C program that stimulates a simple digital clock: #include #include #include void main() { int h,m,s; h=0; m=0; s=0; while(1) { if(s>59) {m=m+1; s=0; } if(m>59) { h=h+1; m=0; } if(h>11) { h=0; m=0; s=0; } delay(1000); s=s+1; clrscr(); printf("\n DIGITAL CLOCK"); printf("\n HOUR:MINUTE:SECOND"); printf("\n%d:%d:%d",h,m,s); }}
on the keyboard. ''m'' is next to ''n'' and ''s'' is next to ''a'' and ''d''.
#include <stdio.h> #include <time.h> int main() { time_t start_time; time_t stop_time; int e; clrscr(); printf( "Type the Enter key to START timing.\n"); while(getchar()!='\n'); start_time=time(NULL); printf( "Type the Enter key to STOP timing.\n"); while(getchar()!='\n'); stop_time=time(NULL) ; e=difftime( stop_time,start_time); printf( "Elapsed time: %d seconds.\n" ,e) ; getch(); }
Decode - A M L A E S T T A N G D A
# include <stdio.h> # include <conio.h> # include <stdlib.h> # define sz 20 # define INF 200000 void print(unsigned long s[][sz], int i, int j) { if (i == j) printf(" A%d ",i); else { printf(" ( "); print(s, i, s[i][j]); print(s, s[i][j] + 1, j); printf(" ) "); } } void printm(unsigned long m[][sz], int n) { int i,j; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { printf("%5d",m[i][j]); } printf("\n\n"); } printf("\nThe No. of multiplication required is : %d",m[1][n]); } void Matrix_Chain_Order(int p[],int num) { unsigned long m[sz][sz] = {0}; unsigned long s[sz][sz] = {0}; unsigned int q = 0; int i, j, k, l; int n = num; for(i = 1; i <= n; i++) m[i][i] = 0; for(l = 2; l <= n; l++) for(i = 1; i <= (n - l + 1); i++) { j = i + l - 1; m[i][j] = INF; for(k = i; k <= j - 1; k++) { q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]; if(q < m[i][j]) { m[i][j] = q; s[i][j] = k; } } } print(s, i-1, j); printf("\n\n"); printf("The Minimum No. of Multiplication Required is:\n\n"); printm(m,n); } void main() { int i,num=0,p[sz]={0}; clrscr(); printf("Enter the number of matrix : "); scanf("%d",&num); printf("Enter %d no. of order sequence for %d matrix :\n",num+1,num); for(i=0;i<=num;i++) scanf("%d",&p[i]); printf("\n\n"); printf("MULTIPLICATION SEQUENCE IS : "); printf("\n\n\t"); Matrix_Chain_Order(p,num); getch(); }
It is spelled "a-n-t-i-d-i-s-e-s-t-a-b-l-i-s-h-m-e-n-t-a-r-i-a-n-i-s-m".
The correct spelling is 'A-n-t-i-d-i-s-e-s-t-a-b-l-i-s-h-m-e-n-t-a-r-i-a-n-i-s-m'.
J a m e s m a d i s o n
According to SOWPODS (the combination of Scrabble dictionaries used around the world) there are 1 words with the pattern M-N-M-S-D. That is, nine letter words with 1st letter M and 3rd letter N and 5th letter M and 7th letter S and 9th letter D. In alphabetical order, they are: minimised
#include<stdio.h> #include<conio.h> void main() { clrscr(); int r=0,d,m,n; printf("Enter a value="); scanf("%d",&n); m=n; do { d=m%10; m=m/10; r=(r*10)+d; } while(m!=0); printf("%d is the reverse",r); getch(); }
/* PROGRAM BY SOUMEN KARMAKAR College of Engineering and Management ,Kolaghat 3rd Year Information Technology Note: Compile the program under Linux environment using gcc. If you want to compile it under turbo c then modify the program */ // Program to solve matrix Minima (Transportation Problem) #include <stdio.h> void input_data(int a[][10],int b[][10],int s[10],int d[10]); void show_data(int a[][10],int b[][10],int s[10],int d[10]); void matrix_min(int a[][10],int b[][10],int s[10],int d[10]); int m,n; int main(void) { int a[10][10],b[10][10],s[10],d[10]; printf("\nEnter the no of supply & demand\n"); scanf("%d %d",&m,&n); input_data(a,b,s,d); show_data(a,b,s,d); matrix_min(a,b,s,d); return (0); } void input_data(int a[][10],int b[][10],int s[10],int d[10]) { int i,j; printf("\nEnter the cost matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&a[i][j]); } for(i=0;i<m;i++) { for(j=0;j<n;j++) b[i][j]=-1; } printf("\nEnter the supply \n"); for(i=0;i<m;i++) scanf("%d",&s[i]); printf("\nEnter the demand\n"); for(i=0;i<n;i++) scanf("%d",&d[i]); } void show_data(int a[][10],int b[][10],int s[10],int d[10]) { int i,j; printf("\n \t\t\tSupply\n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { printf("%d (%d) ",a[i][j],b[i][j]); } printf(" | %d",s[i]); } printf("\n------------------------\n"); printf("\nDemand "); printf("%d ",d[i]); } void matrix_min(int a[][10],int b[][10],int s[10],int d[10]) { int i,j,s1,d1,cost,min,t1,t2,sd; int tag[10][10]; s1=0; d1=0; for(i=0;i<m;i++) { s1=s1+s[i]; } printf("\nsupply= %d",s1); for(j=0;j<n;j++) { d1=d1+d[j]; } printf("\ndemand= %d",d1); if(s1!=d1) printf("\nIt is unbalanced\nSo new table is\n\n"); if(s1>d1) { n++; for(i=0;i<m;i++) { a[i][n-1]=0; b[i][n-1]=-1; } d[n-1]=s1-d1; d1=s1; show_data(a,b,s,d); } else if(s1<d1) { m++; for(j=0;j<n;j++) { a[m-1][j]=0; b[m-1][j]=-1; } s[m-1]=d1-s1; s1=d1; show_data(a,b,s,d); } //MAIN CALCULATION for(i=0;i<m;i++) { for(j=0;j<n;j++) { tag[i][j]=-1; } } printf("\nTag matrix \n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { printf("%d ",tag[i][j]); } } cost=0; sd=0; while(sd!=s1) { for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(tag[i][j]==-1) { min=a[i][j]; t1=i; t2=j; break; } } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(tag[i][j]==-1) { if(min>a[i][j]) { min=a[i][j]; t1=i; t2=j; } } } } printf("\nMin =%d\n",min); if(d[t2]==s[t1]) { cost=cost+a[t1][t2]*s[t1]; b[t1][t2]=s[t1]; sd=sd+s[t1]; d[t2]=0; s[t1]=0; show_data(a,b,s,d); for(j=0;j<n;j++) { if(tag[t1][j]==0) continue; tag[t1][j]=0; } for(i=0;i<m;i++) { if(tag[i][t2]==0) continue; tag[i][t2]=0; } printf("\nTag matrix \n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { printf("%d ",tag[i][j]); } } } else if(d[t2]>s[t1]) { cost=cost+a[t1][t2]*s[t1]; b[t1][t2]=s[t1]; sd=sd+s[t1]; d[t2]=d[t2]-s[t1]; s[t1]=0; show_data(a,b,s,d); for(j=0;j<n;j++) { if(tag[t1][j]==0) continue; tag[t1][j]=0; } printf("\nTag matrix \n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { printf("%d ",tag[i][j]); } } } else { cost=cost+a[t1][t2]*d[t2]; b[t1][t2]=d[t2]; sd=sd+d[t2]; s[t1]=s[t1]-d[t2]; d[t2]=0; show_data(a,b,s,d); for(i=0;i<m;i++) { if(tag[i][t2]==0) continue; tag[i][t2]=0; } printf("\nTag matrix \n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { printf("%d ",tag[i][j]); } } } } printf("\nCost is =%d\n",cost); } // Thank You.........