Results 1 to 4 of 4

Thread: Can translate?

  1. #1
    workmason is offline Member
    Join Date
    Oct 2010
    Posts
    1
    Rep Power
    0

    Default Can translate?

    Hey guys, I know this is ridiculous. But I'm really dumb in JAVA Programming.
    I wrote these codes in C, but I need to submit it in JAVA codes. Can someone help me out on this? Can someone translate it for me?

    Java Code:
    #include<stdio.h>
    #define SZ 1001
    #define MIN(a,b) ((a)<(b)?(a):(b))
    int a[SZ][SZ][11];
    int n,k,i,j,x,s,p,q,size;
    int main(){
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    scanf("%d",&a[i][j][0]);
    for(p=1,s=1;(1<<p)<=k;p++,s*=2)
    for(i=0;i+s<n;i++)
    for(j=0;j+s<n;j++)
    a[i][j][p] = MIN( MIN(a[i][j][p-1],a[i+s][j+s][p-1]) , MIN(a[i+s][j][p-1],a[i][j+s][p-1]) );
    s = 0;
    while(2*(1<<s)<=k) s++;
    x = k - (1<<s);
    for(i=0;i+k<=n;i++){
    for(j=0;j+k<=n;j++){
    printf("%d",MIN( MIN(a[i][j][s],a[i+x][j+x][s]) , MIN(a[i+x][j][s],a[i][j+x][s]) ));
    if(j+k!=n) printf(" ");
    }
    if(i+k!=n) printf("\n");
    }
    return 0;
    }

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    This ain't a "here's my problem, now code this for me site", so for gosh sake, put in at least some effort. You can find the tutorials here: The Really Big Index

    These should get you started in learning how to code Java. Then please feel free to come on back when you show that you're willing to put in at least as much effort as you ask of us.

  3. #3
    joshdgreen's Avatar
    joshdgreen is offline Senior Member
    Join Date
    Oct 2010
    Location
    Colorado Springs, CO
    Posts
    212
    Rep Power
    4

    Default

    Do you know any Java at all? And what is this for, school?
    Sincerely, Joshua Green
    Please REP if I help :)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,950
    Rep Power
    19

    Default

    You wrote that in C?
    Without any indentation?

    ...

    ETA: What does it do?

Similar Threads

  1. Translate from C to java
    By ighor10 in forum New To Java
    Replies: 6
    Last Post: 03-27-2010, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •