【目标500道第8道】天梯赛L1-035 情人节(15分)

【目标500道第8道】天梯赛L1-035 情人节(15分)

//输入样例1:
//GaoXZh
//Magi
//Einst
//Quark
//LaoLao
//FatMouse
//ZhaShen
//fantacy
//latesum
//SenSen
//QuanQuan
//whatever
//whenever
//Potaty
//hahaha
//.
//输出样例1:
//Magiand Potaty are inviting you to dinner...
//输入样例2:
//LaoLao
//FatMouse
//whoever
//.
//输出样例2:
//FatMouse is the only one for you...
//输入样例3:
//LaoLao
//.
//输出样例3:
//Momo... No one is for you ...
#include<iostream>
using namespace std;
struct node
{
	string data;
	node* next;
};
int static counter = 0;
void show(node* head)
{
	int i;
	node* q = head;
	if (counter >= 14)
	{
		for (i = 0; i < 1; i++)//循环这儿有时候会不带脑子多写1次
		{
			q = q->next;
		}
		cout << q->data << ' ';
		q = head;
		for (i = 0; i < 13; i++)
		{
			q = q->next;
		}
		cout <<"and"<<' '<< q->data << ' ' << "are inviting you to dinner...";
	}
	else if (counter >= 2 && counter < 14)
	{
		q = head;
		for (i = 0; i < 1; i++)
		{
			q = q->next;
		}
		cout << q->data << ' ' << "is the only one for you...";
	}
	else {
		cout << "Momo... No one is for you ...";
	}
}
int main()
{
	node* head = NULL;
	node* p = head;
	node* s;
	string d;
	int i, j, k;
	cin >> d;
	while (d != ".")
	{
		counter++;
		s = new node;
		s->data = d;
		s->next = NULL;
		if (head == NULL)
			head = s;
		else p->next = s;
		p = s;
		cin >> d;
	}
	show(head);
}
上一篇:Javascript函数节流 (转)


下一篇:500,二战中的传奇救援【上】