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

📄 倒序输出.cpp

📁 一个用C++编写的倒序输出的程序
💻 CPP
字号:
#include<iostream.h>
#include<stdlib.h>
struct sting
{
	char data;
	struct sting *next;
};
sting *creat()                           
{
	sting *head,*p,*q;
	char b;
	q=head=new sting;
	head->next=0;
	cout<<"输入以'@'结尾的字符串:";
	cin>>b;
	while(b!='@')
	{
		p=new sting;                     
	    p->data=b;
		p->next=0;
		q->next=p;
		q=p;
		cin>>b;
	}
	return head;
}
sting *creat1(sting *n)                   
{
	sting *head,*p;
	head=new sting;head->next=0;
	while(n->next!=0)
	{
		p=new sting;                     
	    p->data=n->next->data;
		p->next=head->next;
		head->next=p;
		n=n->next;
	}
	return head;
}
sting *creat();
sting *creat1(sting *n);
void main()
{
	sting *m,*n,*p;
	p=m=creat();                             
	cout<<"输入的字符串为:";
	while(p->next!=0)                          
	{	
		cout<<p->next->data;
		p=p->next;
	}
	n=creat1(m);
	cout<<endl;
	cout<<"倒序输出的结果为:";
	while(n->next!=0)
	{	
		cout<<n->next->data;
		n=n->next;
	}
	cout<<endl;
}

⌨️ 快捷键说明

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