Search
 
SCRIPT & CODE EXAMPLE
 

C

zizag c

#include <stdio.h>
#include <stdlib.h>
 
int main(int c, char **v)
{
	int i, j, m, n, *s;
 
	/* default size: 5 */
	if (c < 2 || ((m = atoi(v[1]))) <= 0) m = 5;
 
	/* alloc array*/
	s = malloc(sizeof(int) * m * m);
 
	for (i = n = 0; i < m * 2; i++)
		for (j = (i < m) ? 0 : i-m+1; j <= i && j < m; j++)
			s[(i&1)? j*(m-1)+i : (i-j)*m+j ] = n++;
 
	for (i = 0; i < m * m; putchar((++i % m) ? ' ':'
'))
		printf("%3d", s[i]);
 
	/* free(s) */
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: imprimir valor no octave 
C :: random number in c 
C :: golden cobblestone modpack 
C :: how to print boolean in c 
C :: c code to python code converter online 
C :: curl authorization header 
C :: send http request in C 
C :: how to open jupyter notebook in local disk D 
C :: lsusb command not found 
C :: arduino digital input pins 
C :: add 2 numbers in c 
C :: get current used proxy windows 7 
C :: dart in android studio 
C :: c number to string 
C :: how to print the first character of a string in c 
C :: c random array 
C :: How to change an array in a function in c 
C :: typedef in c 
C :: merge sort for strings in c 
C :: how to read keyboard input in C 
C :: putchar in c 
C :: struct main function c in unix 
C :: bootstrap form 
C :: how to call function after some time in vue.js 
C :: check whether a number is prime or not in c 
C :: turn a char array into double C 
C :: eliminare file in c 
C :: how to free memory in c 
C :: prime numbers 
C :: C special character display 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =