i was 2asked to develop a project to make mathematical opertaion on matrix but i was forced in the input method that would be [1 2;3 4] for 2x2 matrix and [1 2 3;4 5 6;7 8 9] for 3x3 matrix and i want to know how to take the float numbers from string to array without taking semicolon and spaces [ and] https://cdn.fbsbx.com/hphotos-xfp1/v...=553D30DE&dl=1 13 1696
If you need input like [1 2;3 4] then why do you think you need a string?
I mean, what the user sees is [1 2;3 4] and that doesn't mean using a string.
So display a [
scanf two floats
Display a ;
scanf two more floats
Display a ]
If this program is about matrix mathematics, then get the mathematics working first and then go back and work on the user input format. You can spend a lot of time formatting user input so I would take an easy way out until you have more experience.
the project description is attached in the link it is a project asked from me in faculty of engineering while i have recently studied c++
zmbd 5,501
Expert Mod 4TB
esslam200 - the project description is attached in the link it is a project asked from me in faculty of engineering while i have recently studied c++
Two things here:
1) It is preferable to have a clear and complete description as the post, not as an attachment, especially an attachment stored at a third part site. One little opps, or deletion and the thread becomes worthless.
Along that same line, many of our experts help from within secured network settings (ie work) and the IT has restricted access to offsite storage. This is to protect the company from all sorts of nasties. :)
2) We don't do homework assignments. It's not fair to you nor other students to have the experts do the work for you.
If you want help on a homework assignment, then post your work first - many of us may provide direction in such cases depending on the amount of effort made by the student.
Luuk 1,047
Expert 1GB
hmmmz, and my post was just stating point 2 in the last answer.....
But it got 'moderated'.... ;)
But I more helpful answer from /me would be:
I know of a function called 'split'. I exists in PHP and in C#
The must be some equivalent for it in C++
But did your teacher not tell you a thing? Some stuff on how to solve this assignment MUST have been explained in the lessons you've got.... ;)
- #include <iostream>
-
#include <string>
-
#include <cstdlib>
-
#include <sstream>
-
#include<string>
-
#include<math.h>
-
using namespace std;
-
int main ()
-
{ string a,b,op;
-
float x[100][100],y[100][100],c,d;
-
int nspace1=0,nsemi1=1,nsemi2=1,nspace2=0,n1,n2;
-
-
getline(cin,a);
-
getline(cin,op);
-
getline(cin,b);
-
n1=a.length();
-
for (int i=0;i<n1;i++)
-
{if (a[i]==';')
-
nsemi1++;
-
}
-
n2=b.length();
-
for (int i=0;i<n2;i++)
-
{if (b[i]==';')
-
nsemi2++;
-
}
-
n1=a.length();
-
for (int i=0;i<n1;i++)
-
{if (a[i]==' ')
-
{nspace1++;}
-
-
}
-
nspace1=(nspace1/nsemi1)+1;
-
for (int i=0;i<n2;i++)
-
{if (b[i]==' ')
-
{nspace2++;}
-
-
}
-
nspace2=(nspace2/nsemi2)+1;
-
-
for (int i=0;i<nsemi1;i++)
-
-
{for(int j=0;j<nspace1;j++){x[i][j]=atof(a.c_str());}}
-
for (int i=0;i<nsemi1;i++)
-
{for(int j=0;j<nspace1;j++){cout<<x[i][j]<<" ";}}
-
system ("PAUSE");
-
-
}
now i delivered here but i don,t have idea how to make Inverse or power is not there any idea? - #include <iostream>
-
#include <string>
-
#include <cstdlib>
-
#include <sstream>
-
#include<string>
-
#include<math.h>
-
using namespace std;
-
int main ()
-
{ string a,b,op,c,d,e,f=" ",r,p;
-
float x[100][100],y[100][100],z[100][100];
-
float nspace1=0,nsemi1=1,nsemi2=1,nspace2=0,n1,n2,k,v;
-
-
-
getline(cin,a);
-
if(v==(int)v)
-
{getline(cin,op);
-
}
-
else
-
{cout<<"ERROR";
-
}
-
-
-
if(op=="+"||op=="-"||op=="*"||op=="^"||op=="T"||op=="D"||op=="I"||op=="/")
-
{
-
getline(cin,b);}
-
else
-
{cout<<"ERROR";
-
}
-
-
-
n1=a.length();
-
for (int i=0;i<n1;i++)
-
{if (a[i]==';')
-
nsemi1++;
-
}
-
n2=b.length();
-
for (int i=0;i<n2;i++)
-
{if (b[i]==';')
-
nsemi2++;
-
}
-
n1=a.length();
-
for (int i=0;i<n1;i++)
-
{if (a[i]==' ')
-
{nspace1++;}
-
-
}
-
nspace1=(nspace1/nsemi1)+1;
-
v=nspace1;
-
-
for (int i=0;i<n2;i++)
-
{if (b[i]==' ')
-
{nspace2++;}
-
-
}
-
nspace2=(nspace2/nsemi2)+1;
-
c=a.substr(1,n1-2);
-
d=b.substr(1,n2-2);
-
c=c+";";
-
d=d+";";
-
/*Removing rubbish from string1*/
-
for(int i=0;i<nsemi1;i++)
-
{
-
e=c.insert(c.find(';')," ");
-
e=c.erase(c.find(';'),1);
-
-
-
-
}
-
/*Removing rubbish in string 2*/
-
for(int i=0;i<nsemi2;i++)
-
{
-
f=d.insert(d.find(';')," ");
-
f=d.erase(d.find(';'),1);
-
}
-
-
/*filling array1 from str1*/
-
-
for(int i=0;i<nsemi1;i++)
-
{for (int j=0;j<nspace1;j++)
-
{r=e.substr(0,e.find(' '));
-
x[i][j]=atof(r.c_str());
-
e=e.erase(0,e.find(' ')+1);
-
-
}
-
}
-
/*filling array2 from str2*/
-
for(int i=0;i<nsemi2;i++)
-
{for (int j=0;j<nspace2;j++)
-
{p=f.substr(0,f.find(' '));
-
y[i][j]=atof(p.c_str());
-
f=f.erase(0,f.find(' ')+1);
-
-
}
-
}
-
-
-
-
/*addition*/
-
if(op=="+")
-
{if(nsemi1==nsemi2&&nspace1==nspace2)
-
{
-
cout<<"[";
-
for(int i=0;i<nsemi1;i++)
-
{for(int j=0;j<nspace1;j++)
-
{z[i][j]=x[i][j]+y[i][j];
-
cout<<z[i][j]<<" ";
-
}cout<<";" ;
-
}
-
cout<<"]";}
-
else {cout<<"ERROR";}
-
}
-
-
/*substraction*/
-
if(op=="-")
-
{ if(nsemi1==nsemi2&&nspace1==nspace2)
-
{cout<<"[";
-
for(int i=0;i<nsemi1;i++)
-
{for(int j=0;j<nspace1;j++)
-
{z[i][j]=x[i][j]-y[i][j];
-
cout<<z[i][j]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
}
-
else {cout<<"ERROR";}
-
}
-
-
/* multiplying */
-
-
if(op=="*")
-
{if(nspace1==nsemi2)
-
-
-
-
{
-
cout<<"[";
-
for(int i=0;i<nsemi1;i++)
-
{
-
for(int j=0;j<nspace2;j++)
-
{
-
z[i][j]=0;
-
for(int q=0;q<nsemi2;q++)
-
{
-
z[i][j]=z[i][j]+x[i][q]*y[q][j];
-
}
-
}
-
}
-
-
for(int i=0;i<nsemi1;i++)
-
{
-
for(int j=0;j<nspace2;j++)
-
{
-
cout<<z[i][j]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
-
}
-
else{cout<<"ERROR";
-
}
-
}
-
-
-
-
if(op=="T")
-
{/* Transpose*/
-
for(int i=0;i<nsemi1;i++)
-
{for(int j=0;j<nspace1;j++)
-
{z[i][j]=x[i][j];
-
cout<<z[j][i]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
}
-
-
-
-
-
-
-
-
}
You have already worked out multiplication. But it is not a function you can call.
Make a function out of it: - int Multiply(float* a, float* b, float*c);
So I pass in the addresses of two matrices (a and b) and get the product matrix (c).
Then call this function in your to-be-written power function: - int Power(float* a, float* b, float*c, int exp);
Inside this function you run a loop from 0 to <exp and inside the loop you call the Multiply function. The product matrix (c) replaces one of the other matrices before the loop cycles and the Multiply function is called again.
Inverse power is just 1/matrix where matrix is the power result from the above function. You have already worked out division so you might make a function out of it also so you can use it here.
can u make this function for me
I can't do that because if I did you still would not know how to do this. The basic blocks in C++ are functions and unless you learn how to write functions, you won't be able to write programs.
Read this: http://bytes.com/topic/c/insights/77...rrays-revealed
This article shows how to use arrays friom inside a function.
but i didn,t take pointers in my course belive me Iam beginner and i find complexity to understand this article
I make the inverse and power but there are logical error that i can,t find please can u find it - #include <iostream>
-
#include <string>
-
#include <cstdlib>
-
#include <sstream>
-
#include<string>
-
#include<math.h>
-
using namespace std;
-
int main ()
-
{ string a,b,op,c,d,e,f=" ",r,p;
-
float x[100][100],y[100][100],z[100][100];
-
float nspace1=0,nsemi1=1,nsemi2=1,nspace2=0,n1,n2,v;
-
int pow,nn,k;
-
-
getline(cin,a);
-
if(v==(int)v)
-
{getline(cin,op);
-
}
-
else
-
{cout<<"ERROR";
-
}
-
-
if(op=="+"||op=="-"||op=="*"||op=="/")
-
{
-
getline(cin,b);
-
n2=b.length();
-
for (int i=0;i<n2;i++)
-
{if (b[i]==';')
-
nsemi2++;
-
}
-
for (int i=0;i<n2;i++)
-
{if (b[i]==' ')
-
{nspace2++;}
-
}
-
nspace2=(nspace2/nsemi2)+1;
-
d=b.substr(1,n2-2);
-
d=d+";";
-
/*Removing rubbish in string 2*/
-
for(int i=0;i<nsemi2;i++)
-
{
-
f=d.insert(d.find(';')," ");
-
f=d.erase(d.find(';'),1);
-
}
-
/*filling array2 from str2*/
-
for(int i=0;i<nsemi2;i++)
-
{for (int j=0;j<nspace2;j++)
-
{p=f.substr(0,f.find(' '));
-
y[i][j]=atof(p.c_str());
-
f=f.erase(0,f.find(' ')+1);
-
-
}
-
}
-
}
-
-
n1=a.length();
-
for (int i=0;i<n1;i++)
-
{if (a[i]==';')
-
nsemi1++;
-
}
-
-
n1=a.length();
-
for (int i=0;i<n1;i++)
-
{if (a[i]==' ')
-
{nspace1++;}
-
-
}
-
nspace1=(nspace1/nsemi1)+1;
-
-
v=nspace1;
-
-
-
c=a.substr(1,n1-2);
-
-
c=c+";";
-
-
/*Removing rubbish from string1*/
-
for(int i=0;i<nsemi1;i++)
-
{
-
e=c.insert(c.find(';')," ");
-
e=c.erase(c.find(';'),1);
-
-
}
-
-
/*filling array1 from str1*/
-
-
for(int i=0;i<nsemi1;i++)
-
{for (int j=0;j<nspace1;j++)
-
{r=e.substr(0,e.find(' '));
-
x[i][j]=atof(r.c_str());
-
e=e.erase(0,e.find(' ')+1);
-
-
}
-
}
-
-
-
/*addition*/
-
if(op=="+")
-
{if(nsemi1==nsemi2&&nspace1==nspace2)
-
{
-
cout<<"[";
-
for(int i=0;i<nsemi1;i++)
-
{for(int j=0;j<nspace1;j++)
-
{z[i][j]=x[i][j]+y[i][j];
-
cout<<z[i][j]<<" ";
-
}cout<<";" ;
-
}
-
cout<<"]";}
-
else {cout<<"ERROR";}
-
}
-
-
/*substraction*/
-
if(op=="-")
-
{ if(nsemi1==nsemi2&&nspace1==nspace2)
-
{cout<<"[";
-
for(int i=0;i<nsemi1;i++)
-
{for(int j=0;j<nspace1;j++)
-
{z[i][j]=x[i][j]-y[i][j];
-
cout<<z[i][j]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
}
-
else {cout<<"ERROR";}
-
}
-
-
/* multiplying */
-
-
if(op=="*")
-
{if(nspace1==nsemi2)
-
-
-
{
-
cout<<"[";
-
for(int i=0;i<nsemi1;i++)
-
{
-
for(int j=0;j<nspace2;j++)
-
{
-
z[i][j]=0;
-
for(int q=0;q<nsemi2;q++)
-
{
-
z[i][j]=z[i][j]+x[i][q]*y[q][j];
-
}
-
}
-
}
-
-
for(int i=0;i<nsemi1;i++)
-
{
-
for(int j=0;j<nspace2;j++)
-
{
-
cout<<z[i][j]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
-
}
-
else{cout<<"ERROR";
-
}
-
}
-
-
-
/* Transpose*/
-
if(op=="T")
-
{
-
if(v==(int)v)
-
{
-
cout<<"[";
-
for(int i=0;i<nspace1;i++)
-
{for(int j=0;j<nsemi1;j++)
-
{
-
cout<<x[j][i]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
}
-
else{cout<<"ERROR";
-
}
-
}
-
/*Determinent*/
-
if(op=="D")
-
{
-
if(nsemi1==nspace1)
-
-
{if(nsemi1==2)
-
{cout<<(x[0][0]*x[1][1]-x[0][1]*x[1][0]);}
-
-
else if(nsemi1==3)
-
{cout<<(((x[0][0])*((x[2][2]*x[1][1])-(x[2][1]*x[1][2])))
-
-((x[1][0])*((x[0][1]*x[2][2])-(x[0][2]*x[2][1])))+
-
((x[2][0])*((x[0][1]*x[1][2])-(x[0][2]*x[1][1]))));
-
-
}
-
else
-
{
-
-
cout<< x[0][0]*((x[1][1]*(x[3][3]*x[2][2]-x[2][3]*x[3][2]))
-
-(x[2][1]*(x[3][3]*x[1][2]-x[1][3]*x[3][2]))+
-
(x[3][1]*(x[2][3]*x[1][2]-x[1][3]*x[2][2])))
-
-
-(x[1][0]*((x[0][1]*(x[2][2]*x[3][3]-x[2][3]*x[3][2]))
-
-(x[2][1]*(x[0][2]*x[3][3]-x[0][3]*x[3][2]))+
-
(x[3][1]*(x[0][2]*x[2][3]-x[0][3]*x[2][2]))))
-
-
+(x[2][0]*((x[0][1]*(x[1][2]*x[3][3]-x[1][3]*x[3][2]))
-
-(x[1][1]*(x[0][2]*x[3][3]-x[0][3]*x[3][2]))+
-
(x[3][1]*(x[0][2]*x[1][3]-x[0][3]*x[1][2]))))
-
-
-(x[3][0]*((x[0][1]*(x[1][2]*x[2][3]-x[1][3]*x[2][2]))
-
-(x[1][1]*(x[0][2]*x[2][3]-x[0][3]*x[2][2]))+
-
(x[2][1]*(x[0][2]*x[1][3]-x[0][3]*x[1][2]))));
-
}
-
-
}
-
else{cout<<"ERROR";}
-
-
}
-
/*power*/
-
if(op=="^")
-
{if(nsemi1==nspace1)
-
{
-
-
cin>>pow;
-
cout<<"[";
-
float mat[100][100];
-
-
for(int k=0;k<pow-1;k++)
-
{
-
for(int i=0;i<nsemi1;i++)
-
{
-
for(int j=0;j<nspace1;j++)
-
{
-
-
for(int m=0;m<nsemi1;m++)
-
{mat[i][j]=x[i][j];
-
z[i][j]=mat[i][j]+mat[i][j]*x[i][j];
-
}
-
}
-
}
-
for(int l=0;l<nsemi1;l++)
-
{
-
for(int ab=0;ab<nsemi1;ab++)
-
{
-
mat[l][ab]=z[l][ab];
-
}
-
-
}
-
}
-
for(int i=0;i<nsemi1;i++)
-
{
-
for(int j=0;j<nspace1;j++)
-
{
-
cout<<z[i][j]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";
-
-
}
-
-
-
else{
-
cout<<"ERROR";
-
}
-
}
-
-
return 0;
-
}
zmbd 5,501
Expert Mod 4TB
esslam200
WFC is a very gracious and generous person and is normally a very helpful expert/moderator - please follow the advice the WFC has already given you:
Please run your compiler and troubleshoot the code. WFC and I have both stated that we cannot do your homework - this is a site policy: Posting Homework or Coursework Questions and Answers
Any and all Homework/Coursework questions will be deleted. If you see a question that is a homework or coursework assignment then please remember DO NOT attempt to post a reply. Replies to this thread will be deleted along with the original post. Please 'report' the thread.
thank u all very much and i must mention WFC who let me think how to solve prgramming problems - #include <iostream>
-
#include <sstream>
-
#include<string>
-
#include<math.h>
-
#include <string>
-
#include <cstdlib>
-
using namespace std;
-
float matrix[100][100],size,d;
-
int i,j;
-
float determinant(float matrix[100][100],float size)
-
{
-
float s=1,det=0,m1[100][100];
-
int i,j,m,n,c;
-
if (size==1)
-
{
-
return (matrix[0][0]);
-
}
-
else
-
{
-
det=0;
-
for (c=0;c<size;c++)
-
{
-
m=0;
-
n=0;
-
for (i=0;i<size;i++)
-
{
-
for (j=0;j<size;j++)
-
{
-
m1[i][j]=0;
-
if (i != 0 && j != c)
-
{
-
m1[m][n]=matrix[i][j];
-
if (n<(size-2))
-
n++;
-
else
-
{
-
n=0;
-
m++;
-
}
-
}
-
}
-
}
-
det=det + s * (matrix[0][c] * determinant(m1,size-1));
-
s=-1 * s;
-
}
-
}
-
-
return (det);
-
}
-
int main ()
-
{
-
string a1,c1,c2,e1,r1,t,b1,v1,v2,e2,r2,l,ope;
-
float x1[100][100],y1[100][100],z1[100][100],k1[100][100],u=0;
-
int i,j,n1,m1,n2,m2,na,nb,sum1=1,sum2=1,a2,a3,a4,a5,b2,b3,b4,b5,q,sum3=1,sum4=1,power;
-
-
getline(cin,a1);
-
a2=a1.length();
-
for (i=0;i<a2;i++)
-
{if (a1[i]==';')
-
sum1 = sum1 +1 ;
-
-
}
-
n1=sum1 ;
-
for (int i=0;i<a2;i++)
-
{if (a1[i]==' ')
-
sum2=sum2+1;
-
if(a1[i]==';')
-
break;
-
}
-
m1=sum2;
-
c2=a1.substr(1,a2-2);
-
c2=c2+";";
-
t= " ";
-
for ( i =0; i<n1;i++)
-
{
-
-
e1 = c2.substr(0,(c2.find(';')));
-
t= t +" "+e1;
-
c2=c2.erase(0,c2.find(';')+1);
-
}
-
a3= t.length();
-
t=t.substr(1);
-
t=t.substr(1);
-
for( i=0;i<n1;i++)
-
{for ( j=0;j<m1;j++)
-
{a4=t.find(' ');
-
a5=t.find(' ');
-
r1=t.substr(0,a4);
-
x1[i][j]=atof(r1.c_str());
-
t=t.erase(0,a5+1);
-
}
-
}
-
getline(cin,ope);
-
if(ope=="-"||ope=="+"||ope=="/"||ope=="*")
-
{
-
getline(cin,b1);
-
b2=b1.length();
-
for (i=0;i<b2;i++)
-
{if (b1[i]==';')
-
sum3 = sum3 +1 ;
-
-
}
-
n2=sum3 ;
-
for ( i=0;i<b2;i++)
-
{if (b1[i]==' ')
-
sum4=sum4+1;
-
if(b1[i]==';')
-
break;
-
}
-
m2=sum4;
-
v2=b1.substr(1,b2-2);
-
v2=v2+";";
-
l= " ";
-
for ( i =0; i<n2;i++)
-
{
-
-
e2 = v2.substr(0,(v2.find(';')));
-
l= l +" "+e2;
-
v2=v2.erase(0,v2.find(';')+1);
-
}
-
b3= l.length();
-
l=l.substr(1);
-
l=l.substr(1);
-
for( i=0;i<n2;i++)
-
{for ( j=0;j<m2;j++)
-
{b4=l.find(' ');
-
b5=l.find(' ');
-
r2=l.substr(0,b4);
-
y1[i][j]=atof(r2.c_str());
-
l=l.erase(0,b5+1);
-
}
-
}
-
if(ope=="+"){
-
if(n1==n2&&m1==m2)
-
{
-
cout<<"[";
-
-
for(i=0;i<n1;i++)
-
{for( j=0;j<m1;j++)
-
{z1[i][j]=x1[i][j]+y1[i][j];
-
if(j!=(m1-1))
-
cout<<z1[i][j]<<" ";
-
else
-
cout<<z1[i][j];
-
-
}
-
if(i!=(n1-1))
-
cout<<";";
-
else
-
continue;
-
-
}
-
cout<<"]";
-
-
}
-
else {cout<<"ERROR";}
-
-
}
-
-
if(ope=="-")
-
{if(n1==n2&&m1==m2)
-
{
-
cout<<"[";
-
-
for(i=0;i<n1;i++)
-
{for( j=0;j<m1;j++)
-
{z1[i][j]=x1[i][j]-y1[i][j];
-
if(j!=(m1-1))
-
cout<<z1[i][j]<<" ";
-
else
-
cout<<z1[i][j];
-
-
}
-
if(i!=(n1-1))
-
cout<<";";
-
else
-
continue;
-
-
}
-
cout<<"]";
-
-
}
-
else {cout<<"ERROR";}
-
-
}
-
-
if(ope=="*")
-
{if(m1==n2)
-
-
-
-
{
-
cout<<"[";
-
for(int i=0;i<n1;i++)
-
{
-
for(int j=0;j<m2;j++)
-
{
-
z1[i][j]=0;
-
for(int q=0;q<n2;q++)
-
{
-
z1[i][j]=z1[i][j]+x1[i][q]*y1[q][j];
-
}
-
}
-
}
-
-
for(int i=0;i<n1;i++)
-
{
-
for(int j=0;j<m2;j++)
-
{
-
if(j!=(m2-1))
-
cout<<z1[i][j]<<" ";
-
else
-
cout<<z1[i][j];
-
-
}
-
if(i!=(n1-1))
-
cout<<";";
-
else
-
continue;
-
-
}
-
cout<<"]";
-
-
}
-
else {cout<<"ERROR";}
-
-
}
-
if(ope=="/"){
-
if(m1==n2){
-
-
float raa[100][100],rbb[100][100];
-
int p,q,m,n,i,j;
-
for (q=0;q<n1;q++)
-
{
-
for (p=0;p<n2;p++)
-
{
-
m=0;
-
n=0;
-
for (i=0;i<n2;i++)
-
{
-
for (j=0;j<n2;j++)
-
{
-
if (i != q && j != p)
-
{
-
raa[m][n]=y1[i][j];
-
if (n<(n2-2))
-
n++;
-
else
-
{
-
n=0;
-
m++;
-
}
-
}
-
}
-
}
-
rbb[q][p]=pow(-1,q + p) * determinant(raa,n2-1);
-
}
-
}
-
float kaa[100][100],d1;
-
-
for (i=0;i<n2;i++)
-
{
-
for (j=0;j<n2;j++)
-
{
-
kaa[i][j]=rbb[j][i];
-
}
-
}
-
d=determinant(y1,n2);
-
for (i=0;i<n2;i++)
-
{
-
for (j=0;j<n2;j++)
-
{
-
y1[i][j]=kaa[i][j] / d;
-
}
-
}
-
for(int i=0;i<n1;i++)
-
{
-
for(int j=0;j<m2;j++)
-
{
-
z1[i][j]=0;
-
for(int q=0;q<n2;q++)
-
{
-
z1[i][j]=z1[i][j]+x1[i][q]*y1[q][j];
-
}
-
}
-
}
-
-
-
cout<<"[";
-
for(int i=0;i<n1;i++)
-
{
-
for(int j=0;j<m2;j++)
-
{
-
if(j!=(m2-1))
-
cout<<z1[i][j]<<" ";
-
else
-
cout<<z1[i][j];
-
-
}
-
if(i!=(n1-1))
-
cout<<";";
-
else
-
continue;
-
-
}
-
cout<<"]";
-
-
}
-
else cout<<"ERORR";
-
}
-
-
-
}
-
-
-
-
-
else if(ope=="^"||ope=="T"||ope=="D"||ope=="I")
-
{
-
-
if(ope=="T"){
-
for (int i=0;i<a2;i++)
-
{if (a1[i]==' ')
-
{u++;}
-
-
}
-
u=(u/n1)+1;
-
int s = u;
-
if(u!= s){
-
cout<<"ERORR";}
-
else {
-
-
cout<<"[";
-
for( int i=0;i<m1;i++)
-
{for( j=0;j<n1;j++)
-
{
-
-
cout<<x1[j][i]<<" ";
-
}
-
cout<<";" ;
-
}
-
cout<<"]";}}
-
-
if(ope=="D"){
-
if(n1!=m1)
-
cout<<"ERORR";
-
-
cout<<determinant(x1,n1);
-
}
-
if(ope=="^"){
-
if(n1==m1)
-
{
-
-
cin>>power;
-
cout<<"[";
-
-
for(i=0;i<n1;i++)
-
{
-
for(j=0;j<m1;j++)
-
{
-
z1[i][j]=x1[i][j];
-
}
-
}
-
-
float t =0;
-
for(int m=0;m<power-1;m++)
-
{
-
for( i=0;i<n1;i++)
-
{
-
for( j=0;j<m1;j++)
-
{
-
for(q=0;q<m1;q++)
-
{
-
t=t+z1[i][q]*x1[q][j];
-
}
-
k1[i][j]=t;
-
t=0;
-
}
-
}
-
for( i=0;i<n1;i++)
-
{
-
for( j=0;j<m1;j++)
-
{
-
z1[i][j]=k1[i][j];
-
}
-
}
-
}
-
-
-
-
for( i=0;i<n1;i++)
-
{
-
for( j=0;j<m1;j++)
-
{
-
if(j!=(m1-1))
-
cout<<z1[i][j]<<" ";
-
else
-
cout<<z1[i][j];
-
-
}
-
if(i!=(n1-1))
-
cout<<";";
-
else
-
continue;
-
-
}
-
cout<<"]";
-
-
}
-
-
else{cout<<"ERROR";
-
-
}
-
}
-
}
-
if(ope=="I"){
-
if(n1==m1)
-
{
-
cout<<"[";
-
float r11[100][100],r22[100][100];
-
int p,q,m,n,i,j;
-
for (q=0;q<n1;q++)
-
{
-
for (p=0;p<n1;p++)
-
{
-
m=0;
-
n=0;
-
for (i=0;i<n1;i++)
-
{
-
for (j=0;j<n1;j++)
-
{
-
if (i != q && j != p)
-
{
-
r11[m][n]=x1[i][j];
-
if (n<(n1-2))
-
n++;
-
else
-
{
-
n=0;
-
m++;
-
}
-
}
-
}
-
}
-
r22[q][p]=pow(-1,q + p) * determinant(r11,n1-1);
-
}
-
}
-
float k11[100][100],d;
-
-
for (i=0;i<n1;i++)
-
{
-
for (j=0;j<n1;j++)
-
{
-
k11[i][j]=r22[j][i];
-
}
-
}
-
d=determinant(x1,n1);
-
for (i=0;i<n1;i++)
-
{
-
for (j=0;j<n1;j++)
-
{
-
z1[i][j]=k11[i][j] / d;
-
}
-
}
-
-
for (i=0;i<n1;i++)
-
{
-
for (j=0;j<n1;j++)
-
{
-
cout<<z1[i][j]<<" ";
-
}
-
cout<<";";
-
}
-
cout <<"]";
-
}
-
else cout<< "ERROR";
-
}
-
return 0;
-
}
-
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt |
last post by:
Any progammers looking for a killer app to develop? How about a voice
enabled forum?
One of the most powerful, exciting, and engrossing experiences on the
Internet is the Forum. The first great...
|
by: memocan |
last post by:
#include <iostream>
using namespace std;
int x; //global variable matrix
int main()
{
x= new float ; //initialize the size now
}
|
by: nestini |
last post by:
Hello everybody,
I am student who just begin learning about programming
I want to know what is Sprase Matrix.
And would you please show me how to add the 2 Sprase Matrix in C
soursecode.
|
by: L. |
last post by:
Hello,
I need to generate random Matrices (say of size 5*5), each with an
average of X (say X=0.5), but with different values’ range. One
matrix should have values in the range of 0-1, while...
|
by: Brad |
last post by:
When debugging my current web project, in VS2003, I found I had lost the
ability to drill down on watch objects in the Watch Window; I could only
view the single value specific watch objects.
...
|
by: Gary Kahrau |
last post by:
If I create a solution that contains (2) projects.
ProjMain and Proj2.
Each project has a form1.
I want to press a button in ProjMain and show form1 of Proj2.
How do I do this?
Gary...
|
by: barry |
last post by:
Hi
Which IDE is used to develop project using .ASP and global.asa files, Visual
Studio 2003 allows creating of C# projects which use .apsx , c# files, i
have not been able to see any option to...
|
by: Daniel Crespo |
last post by:
Hi to all,
Does anyone know about how to make a dot matrix printer print a PDF
file with the quality of a Microsoft Word printing?
When I print from Microsoft Word, the output is perfect for...
|
by: Thomas Bauer |
last post by:
Hello,
how can I make the transformation matrix?
Zero point
Left top
Left bottom
Right top
Right bottom
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |