C_and_CPP 板


LINE

※ 引述《MOONRAKER (㊣快使用弯曲速度,舰长!)》之铭言: : ※ 引述《richardl003 (飞行岩)》之铭言: 经过这位大大的解释 我独自参考书写了几天 终於写了以下的程式码 #include <cstdlib> #include <ctime> #include <iostream> using namespace std; class node{ public: node *last; int data; int order; node *next; private: }; int main( int a, char * b[] ) { int i; srand((unsigned)time(0)); node *head, *tmp0, *tmp1, *end; head = new node; head->last = NULL; head->next = NULL; head->order=0; head->data = rand()%atoi(b[2]); tmp0 = head; for (int i=1; i<atoi(b[1]); i++) { tmp1 = new node; tmp1->last = tmp0; tmp1->next = NULL; tmp1->data = rand()%atoi(b[2]); tmp1->order=i; tmp0->next = tmp1; tmp0 = tmp1; } end = tmp1; tmp0 = head; while (tmp0 != NULL) { cout << tmp0->data << ','; tmp0 = tmp0->next; } cout << endl; tmp0 = end; while (tmp0 != NULL) { cout << tmp0->data << ','; tmp0 = tmp0->last; } cout << endl; tmp0 = head; while (tmp0 != NULL) { if(tmp0->order==6)cout<<"31337,"; cout << tmp0->data << ','; tmp0 = tmp0->next; } cout << endl; system("pause"); } 可是老师把我的程式退了回来 说我没有达成他题目的要求 可是我明明都有跑出来了 请问大家我错在哪里 : : 这是我们第一次的作业 : : 但我看也看不懂 : : 再这个版爬文爬了很九 : : 但是还是不知道该怎麽做 : : 请问我该买什麽书来看吗 : : 或是可以用中文跟我说这是什麽样的观念吗 : : 该做什麽事 : : 我用字典把每个字查了还是不知道该怎麽做 : : Implements a doubly-linked list – that’s a linked list which is linked : : backward and forward : 做一个双向连结串列;也就是串列里面每一个元素都是狡猾的元素, : 先向後连再向前连(骗你的)。 : : Populates it with X random integer values, between 0 and MAX in value, where : : X and MAX are taken from the command line: : : “dblprog 20 40” would create a linked list with 20 random values in the : : range 0-40. : 然後在此串列中塞进 X 个值域 [ 0, MAX ] 的乱数,其中 X 和 MAX 可以用以下 : 的格式在命令列输入: : "dblprog 20 40" 就是产生 20 个值域为 [ 0, 40 ] 的乱数放进串列里。 : : Prints the list out forwards and then in reverse : : Demonstrates inserting a value 31337 in position 7, and printing the list : : again : 首先正着印出串列,然後倒过来再印一次。(我这把枪是狡猾的枪…) : 把数值 31337 插入到位置 7 的地方,再印一次串列。 : : You must use a class for this! : 注意:以上的一切功能都要写成 class! : : Program should be a command line program in Visual C++ 2008 : : Just submit the .cpp and .h files. Don’t select “precompiled headers” when : : you build please. : : Please name your project “dblprog” – that way, we can grade just by : : cutting and pasting : 程式要用 Visual C++ 2008 写成命令列程式。只要交 .cpp 和 .h 就好了。拜托 : 在建置的时候(或者开专案的时候?)不要选"precompiled headers"选项。 : 请把程式命名为 dblprog ,这样我们评分比较方便。 :   --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.50.10
1F:推 untitle:大概是希望你把要求的功能写成member functions吧 02/18 15:39
2F:推 LawlietDo:You must use a class for this! 02/18 18:46
3F:→ MOONRAKER:你只有node写成class,你老师是希望你写一个list的class 02/18 22:05
4F:→ MOONRAKER:里面要包node class,而且在class里面就要有add print 02/18 22:06
5F:→ MOONRAKER:print_reverse add_at等等功能 所以你被退啦 XD 02/18 22:07







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:iOS站内搜寻

TOP