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

📄 main.cpp

📁 查找链表中倒数第M个元素 其中包含链表原码
💻 CPP
字号:
#include "LList.h"
#include <iostream>
using namespace std;

int main() 
{
	int i;
	int m,n;
	int value;
	LList <int> llist;												//the template contain element's type is int											
	for(i=1;i<=1000;i++)
	{
		llist.append(i);                		
	}
	n = llist.rightLength();										//get the number of totol elements
	do{
	cout << "please input a integer between 1  and "<< n <<endl;
	cin >> m;														//imput m
	}while (m<1||m>n);
	llist.setPos(n-m);												//get the last No.m fence
	llist.getValue(value);											
	cout <<"the last No."<<m<<" element is " <<value<<endl;			//output the last No.m nubmer
	return 0;
}

⌨️ 快捷键说明

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