-
c to java programming
dear readers,
i hope any of u can help me to figure out how to create a matrix
multiplier program in java applet. i hope some of u would answer to my
question. thanks.
below i also posted my matrix program which is in c language as a
reference
#include<stdio.h>
#define MAXROWS 20
#define MAXCOLS 30
void readinput(int a[][MAXCOLS], int nrows, int ncols);
void computemultiply(int a[][MAXCOLS],int b[][MAXCOLS],int c[]
[MAXCOLS],int nrows,int ncols);
void writeoutput(int c[][MAXCOLS],int nrows, int ncols);
main()
{
int nrowa, ncola,nrowb, ncolb;
/*array definitions*/
int a[MAXROWS][MAXCOLS]=0;
int b[MAXROWS][MAXCOLS]=0;
int c[MAXROWS][MAXCOLS]=0;
printf("How many rows for matrix a?\n");
scanf("%d",&nrowa);
printf("How many columns for matrix b?\n");
scanf("%d",&ncola);
printf("How many rows for matrix b?");
scanf("%d",&nrowb);
printf("How many columns for matrix b?");
scanf("%d",&ncolb);
printf("\n\nFirst table:\n");
readinput(a,nrowa,ncola);
printf("\n\nsecond table:\n");
readinput(b,nrowb,ncolb);
computemultiply(a,b,c,nrowa,ncola,nrowb,ncolb);
printf("\n\nSums of the elements:\n\n");
writeoutput(c,nrowa,ncolb);
}
/*read in a table of integers*/
void readinput(int a[][MAXCOLS],int m,int n)
{
int row, col;
for(row=0;row<m;++row)
printf("\nEnter data for row no. %2d\n",row+1);
for(col=0;col<n;++col)
scanf("%d",&a[row][col]);
}
return;
}
/*Multiply the matrices */
void computemultiply(int a[][MAXCOLS],int b[][MAXCOLS],int c[]
[MAXCOLS],int m,int n, int p)
{
int j,k,l;
for(j=0; j<m;++j)
for(k=0;k<p;++K)
{
c[j][k]=0;
for(l=0;l<n;++l)
c[j][k]=c[j][k]+a[j][l]*b[l][k];
}
void writeoutput(int a[][MAXCOLS],int m,int n)
{
int j,k;
for(j=0;j<m;++j)
for(k=0;k<n;++k)
printf("%4d\n",a[j][k];
}
return;
}
-
Re: c to java programming
Dear friend,
There is nothing to be done much to convert this
program to java.
But u seem to be a very lazy person.
U seem to have no knowwledge of java.
Sorry friend, but read java and try it your self.
U will laugh upon yourself once u learn java !
-Ashish
"fong luan" <fongluan@hotmail.com> wrote:
>
>dear readers,
>
> i hope any of u can help me to figure out how to create a matrix
>multiplier program in java applet. i hope some of u would answer to my
>question. thanks.
>
>below i also posted my matrix program which is in c language as a
>reference
>
>
>#include<stdio.h>
>
>#define MAXROWS 20
>#define MAXCOLS 30
>void readinput(int a[][MAXCOLS], int nrows, int ncols);
>void computemultiply(int a[][MAXCOLS],int b[][MAXCOLS],int c[]
>[MAXCOLS],int nrows,int ncols);
>void writeoutput(int c[][MAXCOLS],int nrows, int ncols);
>
>main()
>{
>int nrowa, ncola,nrowb, ncolb;
> /*array definitions*/
>int a[MAXROWS][MAXCOLS]=0;
>int b[MAXROWS][MAXCOLS]=0;
>int c[MAXROWS][MAXCOLS]=0;
>
>printf("How many rows for matrix a?\n");
>scanf("%d",&nrowa);
>printf("How many columns for matrix b?\n");
>scanf("%d",&ncola);
>
>printf("How many rows for matrix b?");
>scanf("%d",&nrowb);
>printf("How many columns for matrix b?");
>scanf("%d",&ncolb);
>
>printf("\n\nFirst table:\n");
>readinput(a,nrowa,ncola);
>
>printf("\n\nsecond table:\n");
>readinput(b,nrowb,ncolb);
>
>computemultiply(a,b,c,nrowa,ncola,nrowb,ncolb);
>printf("\n\nSums of the elements:\n\n");
>writeoutput(c,nrowa,ncolb);
>}
>
>/*read in a table of integers*/
>void readinput(int a[][MAXCOLS],int m,int n)
>{
> int row, col;
> for(row=0;row<m;++row)
> printf("\nEnter data for row no. %2d\n",row+1);
> for(col=0;col<n;++col)
> scanf("%d",&a[row][col]);
> }
> return;
>}
>
>/*Multiply the matrices */
>void computemultiply(int a[][MAXCOLS],int b[][MAXCOLS],int c[]
>[MAXCOLS],int m,int n, int p)
>{
> int j,k,l;
> for(j=0; j<m;++j)
> for(k=0;k<p;++K)
> {
> c[j][k]=0;
> for(l=0;l<n;++l)
> c[j][k]=c[j][k]+a[j][l]*b[l][k];
> }
>
>void writeoutput(int a[][MAXCOLS],int m,int n)
>{
> int j,k;
> for(j=0;j<m;++j)
> for(k=0;k<n;++k)
> printf("%4d\n",a[j][k];
> }
> return;
>}
>
>
>
-
Re: c to java programming
You should not talk in this way, He don't know how to do, that's why he came
here, This is newsgroup is to help me people not tount.
I hope you understand.
"Ashish patel" <patel_ashishr@hotmail.com> wrote:
>
>Dear friend,
>There is nothing to be done much to convert this
>program to java.
>But u seem to be a very lazy person.
>U seem to have no knowwledge of java.
>Sorry friend, but read java and try it your self.
>U will laugh upon yourself once u learn java !
>-Ashish
>
>"fong luan" <fongluan@hotmail.com> wrote:
>>
>>dear readers,
>>
>> i hope any of u can help me to figure out how to create a matrix
>>multiplier program in java applet. i hope some of u would answer to my
>>question. thanks.
>>
>>below i also posted my matrix program which is in c language as a
>>reference
>>
>>
>>#include<stdio.h>
>>
>>#define MAXROWS 20
>>#define MAXCOLS 30
>>void readinput(int a[][MAXCOLS], int nrows, int ncols);
>>void computemultiply(int a[][MAXCOLS],int b[][MAXCOLS],int c[]
>>[MAXCOLS],int nrows,int ncols);
>>void writeoutput(int c[][MAXCOLS],int nrows, int ncols);
>>
>>main()
>>{
>>int nrowa, ncola,nrowb, ncolb;
>> /*array definitions*/
>>int a[MAXROWS][MAXCOLS]=0;
>>int b[MAXROWS][MAXCOLS]=0;
>>int c[MAXROWS][MAXCOLS]=0;
>>
>>printf("How many rows for matrix a?\n");
>>scanf("%d",&nrowa);
>>printf("How many columns for matrix b?\n");
>>scanf("%d",&ncola);
>>
>>printf("How many rows for matrix b?");
>>scanf("%d",&nrowb);
>>printf("How many columns for matrix b?");
>>scanf("%d",&ncolb);
>>
>>printf("\n\nFirst table:\n");
>>readinput(a,nrowa,ncola);
>>
>>printf("\n\nsecond table:\n");
>>readinput(b,nrowb,ncolb);
>>
>>computemultiply(a,b,c,nrowa,ncola,nrowb,ncolb);
>>printf("\n\nSums of the elements:\n\n");
>>writeoutput(c,nrowa,ncolb);
>>}
>>
>>/*read in a table of integers*/
>>void readinput(int a[][MAXCOLS],int m,int n)
>>{
>> int row, col;
>> for(row=0;row<m;++row)
>> printf("\nEnter data for row no. %2d\n",row+1);
>> for(col=0;col<n;++col)
>> scanf("%d",&a[row][col]);
>> }
>> return;
>>}
>>
>>/*Multiply the matrices */
>>void computemultiply(int a[][MAXCOLS],int b[][MAXCOLS],int c[]
>>[MAXCOLS],int m,int n, int p)
>>{
>> int j,k,l;
>> for(j=0; j<m;++j)
>> for(k=0;k<p;++K)
>> {
>> c[j][k]=0;
>> for(l=0;l<n;++l)
>> c[j][k]=c[j][k]+a[j][l]*b[l][k];
>> }
>>
>>void writeoutput(int a[][MAXCOLS],int m,int n)
>>{
>> int j,k;
>> for(j=0;j<m;++j)
>> for(k=0;k<n;++k)
>> printf("%4d\n",a[j][k];
>> }
>> return;
>>}
>>
>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks