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

📄 1380.cpp

📁 给定N个整数
💻 CPP
字号:
#include <iostream>
#include <iomanip>
using namespace std;

struct t
{
	long int  data;
	struct t *next;
}*q,*p,*head;

int main()
{
	int n; 
	head=NULL;
	p=new t;
	q=p;
	cout<<"Please input the n and n numbers:"<<endl;
	while(1)
	{
		p=new t;
		if(!p)
		{
			cout<<"\nApplition Memory falied!\n";
			exit(-1);
		}
		cin>>n;
		if(n==0)   break;
		while(n<1||n>10000)
		{
			cout<<"Input error!\n";
			cin>>n;
		}
		
		long int *a=new long int [n];
		for(int i=0;i<n;i++)
		{	cin>>a[i];
		    if(a[i]>1000000000||a[i]<-1000000000)
			{
				cout<<"Input error!Again:"<<endl;
				cin>>a[i];
			}
		}
		long int b=a[0];
		for(int j=1;j<n;j++)
		{
			if(a[j]>b)
				b=a[j];
		}
		p->data=b;
		if(!head)
			head=p;
		else 
			q->next=p;
		q=p;
	}
	q->next=NULL;
	t *s=head;
	while(s!=NULL)
	{
		cout<<s->data<<endl;
		s=s->next;
	}
	int r;
	cin>>r;
	return 0;
}



⌨️ 快捷键说明

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