C ke MIPS Assembly Converter
ngeElements
void main()
{
int arraysize = 11;
int numbers[arraysize];
int howMany, theNthSmallest, index, i;
printf("Specify how many times to repeat:\n");
scanf("%d", &howMany);
printf("Enter an integer for the Nth smallest:\n");
//read an integer from a user input
scanf("%d", &index);
//if the index is not within the range,
//and if it is smaller, set it to 1, if it is larger,
//set it to the size of the array.
if (index < 1)
{
index = 1;
}
else if (index > arraysize)
{
index = arraysize;
}
i=0;
while (i < howMany)
{
theNthSmallest = findTheNthSmallest(numbers, arraysize, index);
printf("The %d(-th) smallest number is %d\n\n", index, theNthSmallest);
i++;
}
}
Yaci Zhu