ridish 于 2014.12.16 19:11 提问

7个回答

u014487915   2014.12.16 19:20

http://baike.baidu.com/view/7804.htm 自己去查一下就知道啊

caozhy      2014.12.16 19:48

int x = 10;
for (int n = 1; n < x; n++)
{
for (int m = 1; m <= n; m++)
printf("%d\t", p(n) / (p(n - m) * p(m)));
printf("\n");
}

int p(int x)
{
int r = 1;
if (x < 2) return r;
for (int i = 2; i <= x; i++)
r = r * i;
return r;
}

qwe1398775315   2014.12.16 22:54

#include
#include
int tab_num;
//最大行数
int count;
//当前行数
int curline_num;

void printnextline(int *);

int main() {

int* curline;
int i;
curline = malloc(sizeof(int));
printf("输入最大行数\n");
scanf("%d",&count);
tab_num = count-1;
curline_num = 1;
curline = 1;
for(i = 0;i < tab_num
(5/2+1);i++){
printf(" ");//空白处1个空格
}
tab_num-=0.5;
printf("1\n");
printnextline(curline);
return 0;
}
/*
*函数功能：求下一行的值
*参数：

• curline 存储当前行的首地址 / void printnextline(int curline){ int i; int* nextline; nextline = malloc(sizeof(int)*(curline_num+1)); memset(nextline,0,sizeof(int)*(curline_num+1)); for(i=0;i<=curline_num;i++){ if(i == 0){ (nextline+i)=1; continue; } if(i == curline_num){ *(nextline+i)=1; continue; } *(nextline+i)=(curline+i)+*(curline+i-1); } for(i = 0;i < tab_num*(5/2+1);i++){ printf(" ");//空白处1个空格 } tab_num-=0.5; for(i = 0;i<curline_num+1;i++){ printf("%d ",*(nextline+i));//空白处5个空格 } printf("\n"); curline_num++; if(curline_num <count){ printnextline(nextline); }

qwe1398775315   2014.12.16 22:54

#include
#include
int tab_num;
//最大行数
int count;
//当前行数
int curline_num;

void printnextline(int *);

int main() {

int* curline;
int i;
curline = malloc(sizeof(int));
printf("输入最大行数\n");
scanf("%d",&count);
tab_num = count-1;
curline_num = 1;
curline = 1;
for(i = 0;i < tab_num
(5/2+1);i++){
printf(" ");//空白处1个空格
}
tab_num-=0.5;
printf("1\n");
printnextline(curline);
return 0;
}
/*
*函数功能：求下一行的值
*参数：

• curline 存储当前行的首地址 / void printnextline(int curline){ int i; int* nextline; nextline = malloc(sizeof(int)*(curline_num+1)); memset(nextline,0,sizeof(int)*(curline_num+1)); for(i=0;i<=curline_num;i++){ if(i == 0){ (nextline+i)=1; continue; } if(i == curline_num){ *(nextline+i)=1; continue; } *(nextline+i)=(curline+i)+*(curline+i-1); } for(i = 0;i < tab_num*(5/2+1);i++){ printf(" ");//空白处1个空格 } tab_num-=0.5; for(i = 0;i<curline_num+1;i++){ printf("%d ",*(nextline+i));//空白处5个空格 } printf("\n"); curline_num++; if(curline_num <count){ printnextline(nextline); }

qwe1398775315   2014.12.16 22:58
``````#include <stdio.h>
#include <stdlib.h>
int tab_num;
//最大行数
int count;
//当前行数
int curline_num;

void printnextline(int *);

int main() {
int* curline;
int i;
curline = malloc(sizeof(int));
printf("输入最大行数\n");
scanf("%d",&count);
tab_num = count-1;
curline_num = 1;
*curline = 1;
for(i = 0;i < tab_num*(5/2+1);i++){
printf(" ");//空白处1个空格
}
tab_num-=0.5;
printf("1\n");
printnextline(curline);
return 0;
}
/*
*函数功能：求下一行的值
*参数：
*      curline 存储当前行的首地址
*/
void printnextline(int* curline){
int i;
int* nextline;
nextline = malloc(sizeof(int)*(curline_num+1));
memset(nextline,0,sizeof(int)*(curline_num+1));
for(i=0;i<=curline_num;i++){
if(i == 0){
*(nextline+i)=1;
continue;
}
if(i == curline_num){
*(nextline+i)=1;
continue;
}
*(nextline+i)=*(curline+i)+*(curline+i-1);
}
for(i = 0;i < tab_num*(5/2+1);i++){
printf(" ");//空白处1个空格
}
tab_num-=0.5;
for(i = 0;i<curline_num+1;i++){
printf("%d     ",*(nextline+i));//空白处5个空格
}
printf("\n");
curline_num++;
if(curline_num <count){
printnextline(nextline);
}
}
``````

save4me      2014.12.17 00:15
save4me      2014.12.18 09:29