A cold beer, or hot tea :) for the person who can h e l p m e with this one:

i need the code for a program that:

reads data from A04_a, A04_b, A04_k

does the folowing operations :
- all the elements from aij and bij are multiplied by 100 and the are stored in B06_a, and B06_b ;
- To all the elements from B06_b aplies the transfomation bi-bi%2 ;
- it retains in b (mask) only the last octet ;
- Calculate bi*aij->bi
returns B06_a,B06_b,B06_k

Many many many 10x for this :) (really !!!)
That's one for the books...
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define N 10

float a[N][N],b[N][N],a6[N][N],b6[N][N],b6vect[N];

void citeste_mat(float x[N][N], int size)
{
int i,j;
for(i=1;i<=size;i++)
for(j=1;j<=size;j++)
{
printf("[%d,%d]=",i,j); scanf("%f",&x[i][j]);
}
}

void scrie_mat(float y[N][N], int size){
int i,j;
for(i=1;i<=size;i++){
for(j=1;j<=size;j++)
printf("%.2f ",y[i][j]);
printf("\n");
}
}

// Functia MAIN()

void main()
{
int i,j,k,m;

printf("Dati dimensiunea matricilor: "); scanf("%d",&m);

printf("Dati matricea 'a': \n");
citeste_mat(a,m);
printf("Matricea initiala A:\n");
scrie_mat(a,m);
printf("\nDati matricea 'b': \n");
citeste_mat(b,m);
printf("Matricea initiala B:\n");
scrie_mat(b,m);

for(i=1;i<=m;i++)
for(j=1;j<=m;j++){
a6[i][j] = a[i][j]*100;
b6[i][j] = b[i][j]*100;
}
printf("Matricea A*100:\n");
scrie_mat(a6,m);
printf("Matricea B*100:\n");
scrie_mat(b6,m);

for(i=1;i<=m;i++)
b6[i][1] = fmod(b6[i][1],2);
printf("Vectorul B6(i,1) % 2:\n");
scrie_mat(b6,m);

float v[N];
for(i=1;i<=m;i++)
v[i] = b6[i][1];
printf("\n v(i)=B6(i,1):\n");
for(i=1;i<=m;i++)
printf("%.2f\n",v[i]);

for(j=1;j<=m;j++){
v[i] = 0;
for(i=1;i<=m;i++)
b6vect[i] = b6vect[i] + v[i]*a6[i][j];
}

printf("\n Vectorul v(i) * A(i,j):\n");
for(i=1;i<=m;i++)
printf("%.2f\n",b6vect[i]);

for(i=1;i<=m;i++)
b6[i][1] = b6vect[i];

printf("\nAFISARE REZULTATE:\n");
printf("Matricea A06:\n");
scrie_mat(a6,m);
printf("\nMatricea B06:\n");
scrie_mat(b6,m);

getch();

}

An i want to multiply only the elements from the diagonal (aii) ;
come on guys i really really need this ..... ;)
Well I don't believe it's necessary to post you whole problem. No one will just do it for you...

However to * the diagonals I would do something like this:
PSEUDOCODE:
1
2
3
4
5
int end = //whatever your end x or y axis number is
int buffer = //array element in 0,0; //to store the multiplication results
for (int start = 1; start < end; start++){
result *= //array at [start][start]
}
Topic archived. No new replies allowed.