Here is the program for Gauss elimination method #include<iostream.h> #include<conio.h> #include<math.h> void main() {float a[6][6],b[6],x[6],t,s; int i,j,n,k; clrscr(); cout<<"Enter the maximum no. of matrix"<<endl; cin>>n; cout<<"Enter th elements of matrix"<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; } } cout<<"enter the right constant"<<endl; for(i=0;i<n;i++) { cin>>b[i]; } for(k=0;k<n-1;k++) { for(i=k+1;i<n;i++) { t=a[i][k]/a[k][k]; a[i][k]=0; for(j=k;j<n;j++) { a[i][j]=a[i][j]-(t*a[k][i]); } b[i]=b[i]-(t*b[k]); } } x[n-1]=b[n-1]/a[n-1][n-1]; for(i=n-1;i>=0;i--) { s=0; for(j=i+1;j<n;j++) {s=s+(a[i][j]*x[j]); } x[i]=(b[i]-s)/a[i][i]; } cout<<"the solution is"<<endl; for(i=0;i<n;i++) { cout<<"x["<<i<<"]="<<x[i]<<endl; } getch(); } C program for Gauss Jordan method: #include<iostream.h> #include<conio.h> #include<math.h> void main() {float a[6][6],b[6],x[6],t,s; int i,j,n,k; clrscr(); cout<<"Enter the maximum no. of matrix"<<endl; cin>>n; cout<<"Enter th elements of matrix"<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; } } cout<<"enter the right constant"<<endl; for(i=0;i<n;i++) { cin>>a[i][n]; } for(k=0;k<n;k++) { for(i=0;i<n;i++) if(i!=k) { for(j=k+1;j<n+1;j++) { a[i][j]=a[i][j]-(a[i][k]/a[k][k])*a[k][j]); cout<<"the solution is"<<endl; for(i=0;i<n;i++) { x[i]=(a[i][n]/a[i][i]); cout<<"x["<<i<<"]="<<x[i]<<endl; } getch(); }
/* Bubble sort: code snippet only nos to be sorted are in the array named 'n' of size 'N' for(int i=0;i<N-1;i++) for(int j=i+1;j<N-1-i;j++) if(n[j]>n[j+1]) swap(n[j],n[j+1]); */ /* insertion sort int v,j; for(int i=1;i<N;i++) { v=n[j]; for(int j=i-1;j>0&&n[j]>v;j--) n[j+1]=n[j]; n[j+1]=v; } */
If you mean: -4*(n-6) = 12 then the value of n = 3
#include<stdio.h> int main() { int n,i,j,k,a[10][10]; printf("\nEnter the number of nodes: "); scanf("%d",&n); for(i=0; i<n; i++) { for(j=0; j<n; j++) { printf("\nEnter the distance between the host %d%d:", i+1,j+1); scanf("%d",&a[i][j]); } } for(i=0; i<n; i++) { for(j=0; j<n; j++) printf("%d\t",a[i][j]); printf("\n"); } for(k=0; k<n; k++) { for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(a[i][j]>a[i][k]+a[k][j]) a[i][j]=a[i][k]+a[k][j]; } } } for(i=0; i<n; i++) { for(j=0; j<n; j++) { b[i][j]=a[i][j]; if(i==j) b[i][j]=0; } } printf("\nThe output matrix is:\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) printf("%d\t",b[i][j]); printf("\n"); } return 0; }
I don't like - where j' stands for "je", meaning "I" in French.
#include<stdio.h> int main () { int array[6][4] ={19,43,43,23,30,13}; int i,j; for(i=0;i<6;i++) for(j=o;j<4;j++) printf("array[%d][%d]=%d\n,"i.j.array[i][j]); return 0; }
Which have warm legs that legs are warmplacen in animal legs okkk oihh khh khh kjhbb kjjhhhjiiy I j j n n nn k j j j j j j n j j n n
Jordan and judean
printf ("12345 1234 123 12 1\n"); ... or, did you mean to do it with loops ? ... int i, j; for (i=5; i>0; i--) { for (j=1; j<=i; j++) printf ("%d", j); printf (" "); } printf ("\n");
#include<iostream> #include<stdio.h> #include<conio.h> using namespace std; int main() { int a[20][20],b[20][20],c[20][20],i,j,k,m,n,f; cout << "Input row and column of A matrix \n\n"; cin >> n >> m; cout << "\n\nInput A - matrix \n\n"; for(i=0;i<n;++i) for(j=0;j<m;++j) cin >> a[i][j]; cout << "\n\nMatrix A : \n\n"; for(i=0;i<n;++i) { for(j=0;j<m;++j) cout << a[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;++i) for(j=0;j<n;++j) b[i][j]=a[j][i]; cout << "\n\nTranspose of matrix A is : \n\n"; for(i=0;i<m;++i) { for(j=0;j<n;++j) cout << b[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;i++) { for(j=0;j<m;j++){ c[i][j]=0; for(k=0;k<=m;k++) c[i][j]+=a[i][k]*b[k][j]; } } for(i=0;i<m;i++) { for(j=0;j<m;j++) { if((int)c[i][i]==1&&(int)c[i][j]==0) f=1; } } cout<<"\n\n Matrix A * transpose of A \n\n"; for(i=0;i<m;i++) { for(j=0;j<m;j++) cout << c[i][j]; cout << "\n\n"; } if(f==1) cout << "\n\nMatrix A is Orthogonal !!!"; else cout << "\n\nMatrix A is NOT Orthogonal !!!"; getch(); return 0; } -ALOK
What does this mean? The rightmost digit of {eq}n^j{/eq} is the remainder when {eq}n^j{/eq} is divided by {eq}10{/eq}. yep totaly nor random :))
6