yl666
发表于 2015-2-28 15:43:35
激动人心,无法言表!
caijinjjin
发表于 2015-3-1 16:10:32
强烈支持楼主ing……谢谢啊啊
gk-jsj
发表于 2015-3-2 21:53:39
激动人心,无法言表!
我戒撸学汇编
发表于 2015-3-3 11:27:15
真是难得给力的帖子啊。
jsplum
发表于 2015-3-11 11:19:26
给力
yuexinBW
发表于 2015-3-11 17:27:37
学习学习看看
a250608134
发表于 2015-3-11 22:33:40
来看看咯
weiqi7777
发表于 2015-3-12 20:37:47
C语言版
#include"stdio.h"
#include"stdlib.h"
typedef struct node{
int number;
struct node *next;
}list;
int main()
{
list *head;
list *p, *q;
head = (list *)malloc(sizeof(list));
head->next = NULL;
p = head;
int n;
while (1)
{
scanf_s("%d", &n);
if (n == 0)
break;
else
{
q = (list *)malloc(sizeof(list));
q->number = n;
p->next = q;
p = p->next;
p->next = NULL;
}
}
p = head->next;
int i;
for (i = 0; i < 4; i++)
{
if (p != NULL)
p = p->next;
else
break;
}
if (i < 4)
printf("链表长度不足5,打印失败\n");
else
printf("%d\n", p->number);
while (head != NULL)
{
p = head;
head = p->next;
free(p);
}
}
weiqi7777
发表于 2015-3-12 21:10:12
C++版
#include"iostream"
using namespace std;
typedef struct node{
int number;
struct node *next;
}snode;
class list{
private:
snode *head;
public:
list()
{
head = new snode;
head->next = NULL;
}
void insertnode(int n)
{
snode *p;
snode *q;
p = head;
while (p->next!= NULL) //找到链表结尾
p = p->next;
q = new snode;
q->next = NULL;
q->number = n;
p->next = q;
}
int finddata(int j)
{
int i;
snode *p;
p = head;
for (i = 0; i < j; i++)//找到第j个位置
{
if (p != NULL)
p = p->next;
else
break;
}
if (i < j)
return 0;
else
return p->number;
}
void deletelist()
{
snode *p;
while (head != NULL)
{
p = head;
head = head->next;
delete p;
}
}
};
int main()
{
int n;
list *head;
head = new list;
while (1)
{
cin >> n;
if (n != 0)
{
head->insertnode(n);
}
else
break;
}
n = head->finddata(5);
if (n == 0)
cout << "链表长度不足5,读取失败" << endl;
else
cout << n<<endl;
head->deletelist();
}
bricker
发表于 2015-3-13 20:22:58
{:1_1:}
谁也不欠谁
发表于 2015-3-25 12:35:40
第一第二还有思路,就是第三问手动的看不懂
OneSky
发表于 2015-3-25 14:35:22
强烈支持楼主ing……
jiang8609
发表于 2015-3-25 16:59:30
zlkxcnz.lkz
ruoziyan
发表于 2015-3-26 09:44:30
楼主加油,鱼C加油!我们都看好你哦!
hankang81
发表于 2015-4-6 16:08:14
看看了强烈支持楼主ing……
茗芗景
发表于 2015-4-7 19:38:04
强烈支持楼主ing……
weiyic
发表于 2015-4-8 21:39:31
下载来看看!谢谢!
梦想成为C的男人
发表于 2015-4-14 16:46:25
被甲鱼哥哥的声音吸引了
hugaolong
发表于 2015-4-18 15:57:36
真是难得给力的帖子啊。
sdzzb
发表于 2015-4-18 21:26:49
强烈支持楼主ing……