how to convert a c programming to java programming
Armin Steinhoff
Armin at Steinhoff_de
Wed Aug 23 06:42:45 EDT 2000
Hello,
port your C program to JPython ... and compile it to native JAVA.
Regards
Armin
In article <8o04ss$tr9$1 at nnrp1.deja.com>, yiqi at my-deja.com says...
>
>hi,
>
> currently, i was given an assignment to create a program using java
>language. my assignment topic is matrix multiplier, and the program
>should be in java applet. but, i have written out the program in c
>language. as i am not familiar wif java languange, i found a great
>difficulty in converting the language in java. i reli hope u all can
>help me to solve this problem. thanks.
> below is the c language of matrix multiplier application as a
>reference to u all
>
>
>#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;
>}
>
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
More information about the Python-list
mailing list