PPRuNe Forums - View Single Post - C Code Anyone?
Thread: C Code Anyone?
View Single Post
Old 18th Mar 2008, 08:50
  #2 (permalink)  
under_exposed
 
Join Date: Jun 2001
Location: Bristol,UK
Posts: 225
Received 12 Likes on 8 Posts
I do like C

#include <stdio.h>

void main (int argc, char * argv[])
{
int i,j;
int requested_value;

if (argc != 2)
{
printf( "\nUsage: %s value ", argv[0] );
return;
}

requested_value = atoi(argv[1]);

if (requested_value > 1)
{
for (i=1;i<=requested_value;i++)
{
for (j=i+1;j <= requested_value;j++)
{
printf("%d..%d, ",i,j);
}
}
printf("\n");
}
else
{
printf("no range\n");
}


}

(Why are leading spaces removed from posts?)
under_exposed is offline