为什么错了啊
查看原帖
为什么错了啊
704713
AnthonyZHOU楼主2022/8/19 23:56
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 64 
typedef struct Ring
{
	struct Ring *next;
	char element;
} ring;

ring *initRing()
{
	ring *p=NULL;
	ring *temp=(ring*)malloc(sizeof(ring));
	temp->element='a';
	temp->next=NULL;
	p=temp;
	for(int i=2;i<=26;i++)
	{
		ring *a=(ring*)malloc(sizeof(ring));
		a->element='a'-1+i;
		a->next=NULL;
		temp->next=a;
		temp=temp->next;
	}
	temp->next=p;
	return p;
}

int main()
{
	int n;
	char str[SIZE];
	scanf("%d",&n);
	getchar();
	ring *p=initRing();
	gets(str);
	for(int i=0;i<strlen(str);i++)
	{
		ring *temp=p;
		for(int a=0;a<str[i]-'a';a++)
		{
			temp=temp->next;
		}
		for(int j=0;j<n;j++)
		{
			temp=temp->next;
		}
		putchar(temp->element);
	}
}
2022/8/19 23:56
加载中...