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

📄 pex9_8.cpp

📁 数据结构C++代码,经典代码,受益多多,希望大家多多支持
💻 CPP
字号:
#include <iostream.h>
#include <strstream.h>
#pragma hdrstop

#include "strclass.h"
#include "link.h"

// print LinkedList object L
template <class T>
void PrintList(LinkedList<T> &L)
{
	L.Reset();
	if (!L.ListEmpty())
	{
		while(!L.EndOfList())
		{
			cout << L.Data() << "  ";
			L.Next();
		}
		cout << endl;
	}
}

void main(void)
{
	// declare the two linked lists of String objects
	LinkedList<String> tokenlist, optionlist;
	char line[80];
	String S;
	
	// read the whitespace separated tokens into C++ string line
	cout << "Input a line of tokens including options:" << endl;
	cin.getline(line, 80, '\n');

	// declare array-based input object instr. we read the tokens
	// from line using instr
	istrstream instr(line);

	// read tokens until end of line
	while(instr >> S)
		if (S[0] == '-')
			// insert option string at rear of optionlist
			optionlist.InsertRear(S);
		else
			// insert non-option string at rear of tokenlist
			tokenlist.InsertRear(S);

	// print the two lists
	cout << endl << "Options: ";
	PrintList(optionlist);
	cout << "Tokens:  ";
	PrintList(tokenlist);
}
/*
<Run>

Input a line of tokens including options:
copy -r file1 -t file2 -print c:\here

Options: -r  -t  -print
Tokens:  copy  file1  file2  c:\here
*/

⌨️ 快捷键说明

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