Astuto Posted August 29, 2016 at 03:03 PM Report #598451 Posted August 29, 2016 at 03:03 PM Boas, É possível fazer uma matriz por exemplo assim: [1][2][3][4] [5][6][7][8] apenas com 2 for's e dois arrays e que seja possível prosseguir a numeração mantendo a estrutura de 4 digitos por linha?
seuqram Posted August 31, 2016 at 12:59 PM Report #598537 Posted August 31, 2016 at 12:59 PM int array1[4]; int array2[4]; int n = 1; for(int i; i < 4; i++) { array1[i] = n; n++; } for(int i; i < 4; i++) { array2[i] = n; n++; } //2 int array[4][2]; int x = 4; int y = 2; int n = 1; for(int i = 0; i < y; i++) { for(int w = 0; w < x; w++) { array[w][i] = n; n++; } } //3 #define X 4 #define Y 2 int array[X][Y]; int x = X, y = Y - 1; for(int i = 0; i < X * Y; i++) { int old_x = x; int old_y = y; x-- if(x < 0) { x = X - 1; y--; } if(old_x >= X) array[x][y] = 8; else array[x][y] = array[old_x][old_y] - 1; } Claro que não é possivel :]
HappyHippyHippo Posted August 31, 2016 at 03:41 PM Report #598539 Posted August 31, 2016 at 03:41 PM para quem gosta de fazer pouco código : #define WIDTH 4 #define HEIGHT 2 int array[HEIGHT][WIDTH] = {0}, i = 0; for (int * pt = (int *) array; i < WIDTH * HEIGHT; ++i, ++pt) * pt = i; 1 Report IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now