不是每行5个吗?看看下面的程序吧:
#include <stdio.h>
#include <stdlib.h>
#define NPERLINE 5
void print(int npairs) {
static int count = 0;
printf("%10d", npairs);
if(++count % NPERLINE == 0)
printf("\n");
}
int main(void) {
int first, second;
int nmonth;
printf("Input the number of month:\n");
scanf("%d", &nmonth);
first = second = 1;
if(nmonth <= 0)
return EXIT_SUCCESS;
print(1);
if(nmonth == 1)
return EXIT_SUCCESS;
print(1);
if(nmonth == 2)
return EXIT_SUCCESS;
nmonth -= 2;
while(nmonth-- > 0) {
first += second;
second += first;
print(first);
if(nmonth-- > 0) {
print(second);
}
}
printf("\n");
return EXIT_SUCCESS;
}