hOW TO CONVERT C++ TO JAVA CODE?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ImCoder
    New Member
    • Oct 2014
    • 1

    hOW TO CONVERT C++ TO JAVA CODE?

    Hi I'm making a flames game but what i'm using is processing and i think processing reads java code so does anyone of you knwo how to convert c++ code to java code? The code is below:
    or you may look at it in the text file


    ‪#‎include‬<std io.h>
    #include<stdlib .h>
    #include<string .h>
    struct node
    {
    char cha;
    struct node *next;
    };
    void push(struct node** head_ref, char new_data)
    {
    struct node* new_node =(struct node*) malloc(sizeof(s truct node));
    new_node->cha = new_data;
    new_node->next = (*head_ref);
    (*head_ref)= new_node;
    }
    struct node* deleteit(struct node *temp,int n)
    {
    n=n-1;
    int count=1;
    struct node *p,*q;
    while(count<n)
    {
    temp=temp->next;
    count++;
    }
    p = temp->next->next;
    q=temp->next;
    temp->next=p;
    free(q);
    return p;
    }

    int absolute(int x,int y)
    {
    if(y>x)
    return y-x;
    else
    return x-y;
    }
    int main()
    {
    int t;
    scanf("%d",&t);
    while(t--)
    {
    int c[30],d[30],m,x,n=0,i;
    char a[20007],b[20007];
    struct node *head=NULL;
    struct node *tem;
    struct node *temp;
    scanf("%s",a);
    scanf("%s",b);
    x=strlen(a);
    m=strlen(b);
    for(i=0;i<28;i+ +)
    {
    c[i]=0;
    d[i]=0;
    }
    for(i=0;i<x;i++ )
    {
    if(a[i]>='a'&&a[i]<='z')
    c[a[i]-'a']++;
    else
    c[a[i]-'A']++;
    }
    for(i=0;i<m;i++ )
    {
    if(b[i]>='a'&&b[i]<='z')
    d[b[i]-'a']++;
    else
    d[b[i]-'A']++;
    }
    for(i=0;i<28;i+ +)
    n=n+absolute(c[i],d[i]);
    push(&head,'s') ;
    push(&head,'e') ;
    push(&head,'m') ;
    push(&head,'a') ;
    push(&head,'l') ;
    push(&head,'f') ;
    tem=head;
    while(tem->next!=NULL)
    {
    tem=tem->next;
    }
    tem->next=head;
    if(n==0||n==1)
    printf("SISTER\ n");
    else
    {
    temp=deleteit(h ead,n);
    temp=deleteit(t emp,n);
    temp=deleteit(t emp,n);
    temp=deleteit(t emp,n);
    temp=deleteit(t emp,n);
    if(temp->cha=='f')
    printf("FRIENDS \n");
    if(temp->cha=='l')
    printf("LOVE\n" );
    if(temp->cha=='a')
    printf("ADORE\n ");
    if(temp->cha=='m')
    printf("MARRIAG E\n");
    if(temp->cha=='e')
    printf("ENEMIES \n");
    if(temp->cha=='s')
    printf("SISTER\ n");
    }
    }
    return 0;
    }
    Attached Files
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There are various C++ to Java converters but none I know about are 100% accurate. You will need to fuss with the converted code t get the program working.

    The other thing you can do is just call the C++ code Java and start fixing errors. This will be more work but you will better control over the changes.

    Comment

    • Timster
      New Member
      • Aug 2015
      • 1

      #3
      Hallo, you could use this program:
      Download BTOC for free. Source code converter. An adjustable translator from one programming language to another. Nowadays tested as basic to c++ translator.

      Comment

      Working...