Last edited by Luke Skywalker; 08-06-09 at 02:05 AM. Reason: Automerged Doublepost
I am using C++ . Farce if you can tell me what is wrong with array copying I will use java.
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.
#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
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 !![]()
javac Math.java
java Math
This program was for copying array only.
watever, now i made the program to work from java too !!![]()
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
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.
finished this in c++, java strings are giving me a headache
reverse.JPG
There are currently 1 users browsing this thread. (0 members and 1 guests)