Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem

Status
Not open for further replies.

cmeees

Programmer
Oct 5, 2001
4
EE
excercise is next .You have to input 2-massive A.then you have to create new 2-massive B according divideng diagonal -elements to other.and output massive B.


example input output

234 1 3/2 4/2
345 3/4 1 5/4
567 5/7 6/7 1

I hope youll get it the point
 
This is not C code, it will not compile - it is pseudo-code to give you a hand thinking about how you might program such a problem. We can't write programs for you. We're here to help you learn.

Get dimension of matrix rows, cols;

for i = 0; i < rows; i++;
for j = 0; j < cols; j++;
input data to float array[j];
if (j == i) denominator = array[j];

for k = 0; k < cols; k++
array[k] = array[k] / denominator;
 
void solve(int a*,float b*){
int x[3];
for (int i=0;i<3;i++){
int x[0] = a/100;
int x[1] = (a -x[0]*100)/10;
int x[2] = a%10;
for (int j=0;j<3;j++) b[j] = (float)x[j]/x;
}
}

Is it simple?
 
to jfhuang
you choose int[3] .What becames when i want int[10]?
int[3],int[4]......int[9]=??
 
void solve(int a*,float b*,int n){
int x[MAX];
unsigned long aNum=1;
for (int m=0;m<n-1;m++) aNum *=10;
for (int i=0;i<3;i++){
unsigned long aNumber = aNum;
int temp = a;
for (int k =0;k<n;k++){
x[k] = temp/aNumber;
temp = temp - aNumber*x[k];
aNumber /=10;
};
for (int j=0;j<n;j++) b[j] = (float)x[j]/x;
}
}
 
for(i=0;i<n;i++){
for (j=0;j<n;j++)
printf(&quot;%f&quot;, (A[j]/A);
printf;
}/*world easiest program*/
your programs wont compile!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top