实验11-1-9 藏尾诗 (20分)

实验11-1-9 藏尾诗 (20分)
本题要求编写一个解密藏尾诗的程序。

输入格式:
输入为一首中文藏尾诗,一共四句。每句一行,但句子不一定是等长的,最短一个汉字,最长九个汉字。注意:一个汉字占两个字节。

输出格式:
取出每句的最后一个汉字并连接在一起形成一个字符串并输出。同时在末尾输入一个换行符。

输入样例:
悠悠田园风
然而心难平
兰花轻涌浪
兰香愈幽静

输出样例:
风平浪静`

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
	char s[20];
	struct Node* next;
};
struct Node* create();
int main(){
	struct Node *p;
	p=create();
	while(p){
		int i=0;
		while(p->s[i]){
			i++;
		}
		printf("%c%c",p->s[i-2],p->s[i-1]);
		p=p->next;
	}
	return 0;
} 

struct Node* create(){
	struct Node* head,*tail,*p;
	head=tail=NULL;
	int count=0;
	while(count<4){
		p=(struct Node*)malloc(sizeof(struct Node));
		scanf("%s",p->s); 
		if(head==NULL){
			head=p;
		}else{
			tail->next=p;
		}tail=p;
		p->next=NULL;
		count++;
	} 
	return head;
}



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值