| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 389 人关注过本帖
标题:闲,做个练习看看...
取消只看楼主 加入收藏
haroldi
Rank: 1
等 级:新手上路
帖 子:158
专家分:0
注 册:2006-7-22
收藏
 问题点数:0 回复次数:0 
闲,做个练习看看...
#include <stdio.h>
#include <stdlib.h>
typedef struct R{
int v1,v2,prdt;
struct R *NextRs;
}Rs;
typedef struct T{
Rs *NextRs;
struct T *NextTm;
}Tm;
//=========================================================================
void CreateTm(Tm **pTm,int Nums);
void PRN_Tm(Tm *pTm);
//=========================================================================
int main(void)
{
int n = 9;
Tm *pTm;
CreateTm(&pTm,n);
PRN_Tm(pTm);
system("pause");
return 0;
}
//=========================================================================
void CreateTm(Tm **pTm,int Nums)
{
int i,j;
Tm *pa = NULL,*pta = NULL;
Rs *pb = NULL,*ptb = NULL;
*pTm = NULL;
for(i = 1;i <= Nums;i++)
{
if(!(pa = (Tm *)malloc(sizeof(Tm))))
{printf("\nERROR!");exit (1);}
pa->NextTm = NULL;
pa->NextRs = NULL;
for(j = i;j <= Nums;j++)
{
if(!(pb = (Rs *)malloc(sizeof(Rs))))
{printf("\nERROR!");exit (1);}
pb->v1 = i;
pb->v2 = j;
pb->prdt = i*j;
pb->NextRs = NULL;
if(pa->NextRs == NULL)
{ptb = pa->NextRs = pb;continue;}
ptb->NextRs = pb;
ptb = ptb->NextRs;
}
if(*pTm == NULL) {*pTm = pta = pa;continue;}
pta->NextTm = pa;
pta = pta->NextTm;
}
}
//=========================================================================
void PRN_Tm(Tm *pTm)
{
Tm *p = pTm;
Rs *q = NULL;
while(p != NULL)
{
q = p->NextRs;
while(q != NULL)
{
printf("%d×%d=%2d ",q->v1,q->v2,q->prdt);
q = q->NextRs;
}
p = p->NextTm;
printf("\n\n");
}
}
//=========================================================================
搜索更多相关主题的帖子: 练习 
2007-04-06 16:14
快速回复:闲,做个练习看看...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.083370 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved