拉丁方阵问题

拉丁方阵问题

 

        拉丁方阵是一种n×n的方阵,方阵中恰有n种不同的元素,每种元素恰有n个,并且每种元素在一行和一列中 恰好出现一次。

著名数学家和物理学家欧拉使用拉丁字母来作为拉丁方阵里元素的符号,拉丁方阵因此而得名。

#include<stdio.h>
#include<malloc.h>
	struct node
	{
		 int data;     //elementype表示一种数据类型,可能是int/char等等
		 struct node *next;   //next 指针,用于链表结构指向下一个节点
	};
	typedef struct node node; //重定义struct node类型为node

	node* Creat(int n);
	int main()
	{
		int n;
		int i;
		int j;
		node* head;
		scanf("%d",&n);
		head = Creat(n);
		for(i = 0;i < n;i++)
		{
			j = n;
			while(j)
			{
				printf("%d",head->data);
				j--;
				head = head->next;
			}
			printf("\n");
			head = head->next;
		}
		return 0;
	}
	node* Creat(int n)
	{
		node *p = NULL;
		node *head;
		head =(node *)malloc(sizeof(node));
		p = head;
		node *s;
		int i = 1;
		if(0 != n)
		{
			while(i <= n)
			{
				s = (node*)malloc(sizeof(node));
				s->data = i;
				p->next = s;
				p = s;
				i++;
			}
			s->next = head->next;
		}
		free(head);
		return s->next;
	}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值