Vertical Print

Code Id 12
Date Updated 3/7/2010
Title Vertical print  
Description
Write a program that prints its command-line arguments vertically, with
three spaces between adjacent arguments. For example, yourprog WE LOVE
SALAD will print
    W   L   S
    E   O   A
        V   L
        E   A
            D
on five lines, spaced exactly as shown. 
                                  
Codes Snippet
#include 

int main(int argc,char **argv)
{
  int i;

  for (;;) {
    for (i = 1;i < argc;++i) if (*argv[i]) break;
    if (i >= argc) return 0;
    for (i = 1;i < argc;++i) {
      if (i > 1) { putchar(' '); putchar(' '); putchar(' '); }
      putchar(*argv[i] ? *argv[i]++ : ' ');
    }
    putchar('n');
  }
  return 0;
}

Comments are closed.