PPRuNe Forums - View Single Post - C Code Anyone?
Thread: C Code Anyone?
View Single Post
Old 18th March 2008 | 08:50
  #2 (permalink)  
under_exposed
20 Anniversary
 
Joined: Jun 2001
Posts: 238
Likes: 40
From: Bristol,UK
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 online now  
Reply