Page 3 of 5 FirstFirst 12345 LastLast
Results 51 to 75 of 106

Thread: programming challenge...

  1. #51
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Quote Originally Posted by Pri_dm View Post
    yes it worked on dry run

    i = -1;
    n = 0;
    j = 0;
    k = 0;
    l = 0;

    while (n <17)
    {
    if (i < 3)
    i++;
    else
    l++;

    k = 0;
    for (j = 0; j<= i-l; j++)
    {
    char2DArray[i-j][k]=charArray[n];
    n++;
    k++;
    }
    }

    Try this farce ;-)
    Who was your teacher?
    This is good but can't understand head or tail of it in one go.

    Quote Originally Posted by Pri_dm View Post
    even i wanna read ur poetry
    No you don't. It is for advice. I will give you final version before other.

    will come to see response 7 min later.
    Last edited by Luke Skywalker; 08-06-09 at 02:05 AM. Reason: Automerged Doublepost

  2. #52
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by Luke View Post
    class Math
    {
    public static void main(String[] args)
    {

    char[] charArray={'a','b','c','d','e','f','g','h','i','j' ,'k','l','m','n','o','p'};
    char[][] char2DArray=new char[4][4];
    char[][] a=new char[4][4];


    for(int x=0; x<charArray.length; x++){
    for(int d=0; d<char2DArray.length; d++){
    for(int b=0; b<char2DArray[d].length; b++){


    char2DArray[b][d] = (char)charArray[x];


    }}}
    for(int i = 0; i <= 3; i++) {
    System.out.print("");
    for(int j = 0; j <= 3; j++) {
    System.out.print(" " + char2DArray[i][j]);
    }
    System.out.println("");
    }
    System.out.println();
    }
    }

    What the hell had happened that this is not copying?
    @Farce can I pm you my poetry again?
    you want me to debug your program?

    sure, PM me.

    -F

  3. #53
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Now I am using C++. So that farce can help me.

    Quote Originally Posted by farce View Post
    you want me to debug your program?

    sure, PM me.

    -F
    Of course tell me why array is not copying.
    Last edited by Luke Skywalker; 08-06-09 at 02:12 AM. Reason: Automerged Doublepost

  4. #54
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by Pri_dm View Post
    yes it worked on dry run

    i = -1;
    n = 0;
    j = 0;
    k = 0;
    l = 0;

    while (n <17)
    {
    if (i < 3)
    i++;
    else
    l++;

    k = 0;
    for (j = 0; j<= i-l; j++)
    {
    char2DArray[i-j][k]=charArray[n];
    n++;
    k++;
    }
    }

    Try this farce ;-)
    "pri.c" 35 lines, 432 characters
    > !cc
    cc pri.c
    > a.out


    Segmentation Fault (core dumped)
    >


  5. #55
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    I am using C++ . Farce if you can tell me what is wrong with array copying I will use java.

  6. #56
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by Luke View Post
    Now I am using C++. So that farce can help me.



    Of course tell me why array is not copying.
    can you try with 4 instead of xxx.length.

  7. #57
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    "pri.c" 35 lines, 432 characters
    > !cc
    cc pri.c
    > a.out


    Segmentation Fault (core dumped)
    >

    farce, are linux C and borland C the same ? with respect to syntax and all

  8. #58
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Again getting this
    a e i m
    b f j n
    c g k o
    d h l p
    class Math
    {
    public static void main(String[] args)
    {

    char[] charArray={'a','b','c','d','e','f','g','h','i','j' ,'k','l','m','n','o','p'};
    char[][] char2DArray=new char[4][4];
    char[][] a=new char[4][4];


    int c=0;
    for(int d=0; d<char2DArray.length; d++){
    for(int b=0; b<char2DArray[d].length; b++){


    char2DArray[b][d] = (char)charArray[c];

    c ++;
    }}



    for(int i = 0; i <= 3; i++) {
    System.out.print("");
    for(int j = 0; j <= 3; j++) {
    System.out.print(" " + char2DArray[i][j]);
    }
    System.out.println("");
    }
    System.out.println();
    }


    }

    Situation solve ,able to copy now trying to produce as given
    Last edited by Luke Skywalker; 08-06-09 at 02:21 AM. Reason: Automerged Doublepost
    History is on the move,my friends.Those who cannot keep up will be left behind, to watch from distance.And those who stand in its way will not watch at all.http://windows7sins.org/
    People are going to tell stories about me none of which change who I really am.

  9. #59
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by newprouser View Post
    farce, are linux C and borland C the same ? with respect to syntax and all
    should be, I am not sure though.

    -F

  10. #60
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Quote Originally Posted by farce View Post
    can you try with 4 instead of xxx.length.
    In which line?

  11. #61
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    take a string = "abcdefgh";

    reverse this without using any temp variables ;-)

    -F
    wow, i tho this question was only for integers, will try it out tomo

  12. #62
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    #line 1 "/root/mat.cpp"
    /root/mat.cpp:1: error: Can't open include file "iostream.h"
    #include <iostream.h>


    int main()

    {

    char charArray[]={'a','b','c','d','e','f','g','h','i','j','k','l', 'm','n','o','p'};
    char char2DArray[4][4];
    char a[4][4];


    int counter =0;




    for (int column = 0; column < 4; column++) {
    for (int row = 0; row < 4; row++) {
    char2DArray[column][row] = charArray [counter];
    counter++;
    }
    }
    }
    1 error in preprocessor.
    Now what is wrong with using iostream.h?

    Don't reply. should have use g++ compiler as have not link mccp compiler.
    Last edited by Luke Skywalker; 08-06-09 at 02:42 AM. Reason: Automerged Doublepost

  13. #63
    newprouser
    Guest

    Default

    Somebody please explain about this !

    usually the java programs i tried required me to have the "class name" and "file name" to be the same.

    but i am able to run luke's program which starts with "math.class" from a differently named file.

    confused !

  14. #64
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    javac Math.java
    java Math

    This program was for copying array only.

  15. #65
    newprouser
    Guest

    Default

    watever, now i made the program to work from java too !!

  16. #66
    newprouser
    Guest

  17. #67
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Quote Originally Posted by newprouser View Post
    farce, are linux C and borland C the same ? with respect to syntax and all
    Don't know but g++ & turbo c++ are vastly different.

  18. #68
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by newprouser View Post
    watever, now i made the program to work from java too !!
    excellent, now go to the reverse puzzle.

    Next in line after the reverse - write a program that prints itself
    (no googling ;-)

    -F

  19. #69
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    excellent, now go to the reverse puzzle.

    Next in line after the reverse - write a program that prints itself
    (no googling ;-)

    -F
    sure, i ll try it tomo, no use in google, it kills the joy of programming

  20. #70
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    After a comedy of errors have to refer the book & found out some difference between g++ & turco c++:-
    #include <iostream> no.h

    int main()

    {

    char charArray[]={'a','b','c','d','e','f','g','h','i','j','k','l', 'm','n','o','p'};
    char char2DArray[4][4];
    char a[4][4];


    int counter =0;




    for (int column = 0; column < 4; column++) {
    for (int row = 0; row < 4; row++) {
    char2DArray[column][row] = charArray [counter];
    counter++;
    }
    }

    for(int i = 0; i <= 3; i++) {
    std::cout <<std::endl;; no endl or cout simply
    for(int j = 0; j <= 3; j++) {
    std::cout<<char2DArray[i][j];
    std::cout<<" "; }

    }




    }

    I think I shouldn't copy simple here.

    Want to curse my old teacher.

    Programming Challenges - Steven S. Skiena
    Will issue this book from my card. We can all solve the problems given in it. I think it is available in my library.

    This start from basic level challenges. Can't purchase it as it will create a hole in my pocket.
    Last edited by Luke Skywalker; 08-06-09 at 11:10 AM. Reason: Automerged Doublepost

  21. #71
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Don't give answer.

  22. #72
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Please don't post answers till 11pm 6 August.

    Have to go to sleep.G'night. Also will go somewhere.
    Last edited by Luke Skywalker; 08-06-09 at 11:11 AM.

  23. #73
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    take a string = "abcdefgh";

    reverse this without using any temp variables ;-)

    -F
    finished this in c++, java strings are giving me a headache

    reverse.JPG

  24. #74
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by newprouser View Post
    finished this in c++, java strings are giving me a headache
    wow! I am impressed. How did you do it? don't post it here according
    to Luke's request, maybe PM me.

    -F

  25. #75
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    wow! I am impressed. How did you do it? don't post it here according
    to Luke's request, maybe PM me.

    -F
    well it was simpler coz, Turbo C is very lenient, doin in java is the real challenge.

    Sent you PM.

Page 3 of 5 FirstFirst 12345 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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