Advertisement
aaaaaa123456789

JV's programming challenge, week 4, testing code 1

Dec 5th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "week4.c"
  3.  
  4. int main (int argc, char ** argv) {
  5.   if (argc < 2) {
  6.     printf("No size specified. Usage: %s <size>\n", *argv);
  7.     return 1;
  8.   }
  9.   unsigned short size;
  10.   if (!sscanf(argv[1], "%hu", &size)) {
  11.     printf("Invalid size specified.\n");
  12.     return 1;
  13.   }
  14.   unsigned short * result = tour(size);
  15.   if (!result)
  16.     printf("No valid tour found.\n");
  17.   else {
  18.     unsigned short * current;
  19.     printf("(%hu, %hu)", *result, result[1]);
  20.     for (current = result + 2; (current - result) < (2 * size * size); current += 2)
  21.       printf(", (%hu, %hu)", *current, current[1]);
  22.     free(result);
  23.     printf(".\n");
  24.   }
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement