谢谢
#include "stdio.h"
#include "conio.h"
#define MAX 5
main()
{
FILE *fpt;
int set[MAX];
int y;
int m,n,position;
int i,x ;
for(y=20;y<31;y++){
if(y==15)
x=1;
m=15;n=5,x=0;
for(i=0;i<n;i++)
set[i]=i+1;
for(i=0;i<n;i++)
/* printf("%d ", set[i]);
putchar('\n');*/ position=n-1;
while(1)
{
if(set[n-1]==m)
position--;
else
position =n-1;
set[position]++;
for(i=position+1;i<n;i++)
set[i]=set[i-1]+1;
if(set[0]+set[1]+set[2]+set[3]+set[4]==y)
x=x+1;
/*printf("%d ", set[i]);*/
/*putchar('\n');*/
if(set[0] >= m - n + 1)
break; }
putchar('\n'); putchar('\n');
printf("when y= ");
printf("%d",y);
printf(" so you want to look ");
printf("%d",x);
}
getch();
}
#include "stdio.h"
#include "conio.h"
#define MAX 5
main()
{
FILE *fpt;
int set[MAX];
int y;
int m,n,position;
int i,x ;
for(y=20;y<31;y++){
if(y==15)
x=1;
m=15;n=5,x=0;
for(i=0;i<n;i++)
set[i]=i+1;
for(i=0;i<n;i++)
/* printf("%d ", set[i]);
putchar('\n');*/ position=n-1;
while(1)
{
if(set[n-1]==m)
position--;
else
position =n-1;
set[position]++;
for(i=position+1;i<n;i++)
set[i]=set[i-1]+1;
if(set[0]+set[1]+set[2]+set[3]+set[4]==y)
x=x+1;
/*printf("%d ", set[i]);*/
/*putchar('\n');*/
if(set[0] >= m - n + 1)
break; }
putchar('\n'); putchar('\n');
printf("when y= ");
printf("%d",y);
printf(" so you want to look ");
printf("%d",x);
}
getch();
}