目前,我的简单数组程序正在生成我想要的数据,但我希望它采用更清晰的格式,如下所示:
Element[0] = 100 Element[26] = 126
Less than 125 Greater than 125
Element[1] = 101 Element[27] = 127
Less than 125 Greater than 127
等等
#include <stdio.h>
int main ()
{
int arr[ 51 ]; /* arr is an array of 10 integers */
int x,y;
/* initialize elements of arr[] to 0 */
for ( x = 0; x < 51; x++ )
{
arr[ x ] = x + 100; /* set element at int x to x + 100 */
}
/* outputs the value of each arra y element */
for (y = 0; y < 51; y++ )
{
if (y <= 25)
{
printf("Element[%d] = %d\n", y, arr[y]) && printf(" This is less than 125\n");
}
if (y >=26)
{
printf("Element[%d] = %d\n", y, arr[y]) && printf(" This is greater than 125\n");
}
}
return 0;
}
任何帮助将非常感激!