#include #include void usage (char** argv) { printf ("%s : output given line of pascal's triangle\n", argv[0]); } int main (int argc, char** argv) { if (argc != 2) { usage (argv); exit (1); } int line = atoi (argv[1]); if (line == 0) { usage (argv); exit (1); } int* from = calloc (line + 1, sizeof(int)); int* to = calloc (line + 1, sizeof(int)); *from = 1; for (int i = 0; i < line; i++) { to[0] = 1; for (int j = 1; j < (line + 1); j++) { to[j] = from[j - 1] + from [j]; } int* temp = from; from = to; to = temp; } for (int i = 0; i < line; i++) printf ("%3i", to[i]); puts ("\n"); }