⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 三元组.c

📁 C语言数据结构作业三元组序列表
💻 C
字号:
#define OK 1
#define ERROR O
#define OVERFLOW -2
#define MAXSIZE 1000
typedef int ElemType;
typedef int Status;
#include "conio.h"
typedef struct{
	int i,j;
	ElemType e;
}Triple;
typedef struct{
	Triple data[MAXSIZE+1];
	int mu,nu,tu;
}TSMatrix;

Status FastTransposeSMatrix(TSMatrix M,TSMatrix *T) {
int col,p,q,t;
int num[100],cpot[100];
T->mu=M.nu; T->nu=M.mu; T->tu=M.tu;
	if(T->tu){
		for(col=1;col<=M.nu;++col) num[col]=0;
		for(t=1;t<=M.tu;++t) ++num[M.data[t].j];
		cpot[1]=1;
		for(col=2;col<=M.nu;++col) cpot[col]=cpot[col-1]+num[col-1];
		for(p=1;p<M.tu;++p){
			col=M.data[p].j; q=cpot[col];
			T->data[q].i=M.data[p].j;T->data[q].j=M.data[p].i;
			T->data[q].e=M.data[p].e;++cpot[col];
        }
	}	
        return OK;
	}
	
main()
{TSMatrix M,T;
 int ;
 scanf("%d%d%d",&M.mu,&M.nu,&M.tu);
 for(i=1;i<=M.tu;i++)
 {printf("the %d number");
 scanf("%d%d%d",&M.data[i].i,&M.data[i].j,&M.data[i].e);
 }
 FastTransposeSMatrix(M,&T);
 for(i=1;i<=T.tu;i++)
 {printf("%d%d",T.data[i].i,T.data[i].j);
 }
 getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -