You are not logged in.

#1 2015-04-30 14:40:13

ZoLA
Member
Registered: 2014-04-07
Posts: 22

[SOLVED]C some ugly code

#include <stdio.h>
#define N 			4

void main(){
	int a[][N] = {{2},{3,3,1},{1,8,8,2},{3,1}},*b = *a,*c = *(a+N-1),i,j;
		while(b < c) *b++ += *c--;
		for(i = N; i > 0;i--) printf("%d ",(*a)[i-1]);
}

Can somebody explain to me wtf is this? :v

is b type of ( int *b ) and i,j are ( int ), how this works?

Last edited by ZoLA (2015-04-30 14:59:46)

Offline

#2 2015-04-30 14:45:12

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,408

Re: [SOLVED]C some ugly code

No telling for sure, these (b & c) should already be defined.  The *b and *a and *c are pointers.

Last edited by nomorewindows (2015-04-30 14:46:02)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#3 2015-04-30 14:59:22

ZoLA
Member
Registered: 2014-04-07
Posts: 22

Re: [SOLVED]C some ugly code

I found my way around , a[][N] is matrix so type is (int **) after that there is no semicolon so initialization continues soo after that there is (int *b) (int *c) (int i) (int j)..
But thanks dude smile

Offline

#4 2015-04-30 15:05:56

progandy
Member
Registered: 2012-05-17
Posts: 5,279

Re: [SOLVED]C some ugly code

I expanded the code a bit:

#include <stdio.h>
#define N 			4

void main(){
	int a[][N] = {{2},{3,3,1},{1,8,8,2},{3,1}};
	int * b = a[0];
	int * c = a[3];
	int i;
	int j;
	while(b < c) {
		i = c[0];
		c -= 1;
		b[0] += i;
		b += 1;
	}
	for(i = N; i > 0;i--) {
		printf("%d ",a[0][i-1]);
	}
}

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB