溪边树

象一棵树,栽在溪水旁。
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

最新评论

共2页: 1 2 下一页 
Re:Common Programming Errors -- chapter6 feicun 2011-05-20 22:22  
dd
Re:Common Programming Errors -- chapter6 feicun 2010-06-17 00:49  
嗯,谢谢老师
Re:Common Programming Errors -- chapter6 溪边树 2010-06-15 19:23  
@feicun int*temp=0与 int* temp = NULL是相同的,初始化为空指针。 用 *temp 访问一个地址为空的存储单元,当然不行了。 你的程序应该改为: [code=cpp] void swap1(int *p, int *q) { int temp; // 是整型变量,不是指向整数的指针变量! temp = *p; *p = *q; *q = temp; cout <<*p<<*q; } [/code]
Re:Common Programming Errors -- chapter6 feicun 2010-06-15 13:23  
哦,谢谢老师! 但我试着把int*temp=0,好像还是不行。
Re:Common Programming Errors -- chapter6 溪边树 2010-06-15 09:27  
@feicun int* temp定义了一个指针变量 temp,却没有初始化。 temp这个盒子里面的内容是不确定的。 temp = p是没有问题的,是把p的内容放入temp. 但是*temp是指temp所指向的那个盒子的别名,由于temp没有初始化,其内容可能是某个不能改写的内存单元的地址,所以,会出现地址冲突。
Re:Common Programming Errors -- chapter6 feicun 2010-06-15 02:22  
老师: 你好,请看我的程序: void swap1(int *p, int *q) { int *temp; *temp=*p; *p=*q; *q=*temp; cout <<*p<<*q; } //程序在运行时,到了“*temp=*p;"这一句中断了,说什么temp对的地址冲突,这是啥原因、? 谢谢。
Re:Common Programming Errors -- chapter6 溪边树 2010-05-03 21:36  
@fzstar 我想起来了。在Visual C++ 6.0环境下,应该用 #include <cstring>,而不是 #include <string>
Re:Common Programming Errors -- chapter6 fzstar 2010-05-03 18:20  
@溪边树 已经加了啊
Re:Common Programming Errors -- chapter6 溪边树 2010-05-02 08:50  
@fzstar employee.h中, #include<string>的后面是否加上了 using namespace std;?
Re:Common Programming Errors -- chapter6 fzstar 2010-05-01 12:13  
老师,employee那个作业 我把代码分成date.h date.cpp employee.h employee.cpp四个文件就会出现很多问题,主要是识别不出string,但把这四个文件内容全粘贴到一个文件中就没有问题了,请问这是什么原因? 各文件头如下: date.h (无) date.cpp #include <iostream> #include <iomanip> #include "date.h" employee.h #include <string> #include "date.h" employee.cpp #include <iostream> #include "employee.h"
Re:Good Programming Practices -- Chapter 6 林旭 2010-04-09 19:08  
老师,我把搜索收入区间这样改了: while ( income > rules[i].M && i < n ) { j = i ; i = i + 1 ; } i ,j的初始值都是0,j记住收入所在区间,“i<n”为了防止越界 这样找到一个income<rules[i].M就跳出循环了
Re:Common Programming Errors -- chapter6 溪边树 2010-04-05 18:58  
@林旭 呵呵,通过这两个函数可以让收音机的音量数字动起来。模拟按住提高音量按钮时,音量数字不断增加的情形。 在输出'\b'字符,可以让光标后退一个字符。 比如输出了“How are you!”之后,再输出'\b',光标将回到叹号处。 本来上课时要给你们演示一下的,结果没有时间了。
Re:Common Programming Errors -- chapter6 林旭 2010-04-05 14:20  
老师,作业3里面的 void delay(); void clear(); 两个函数没给注释,要实现什么功能?
Re:C语言中数组名和指针的区别 溪边树 2010-03-31 19:11  
@林旭 请看前面的那个注释,求最右边的点的函数名为Rightmost().
Re:C语言中数组名和指针的区别 林旭 2010-03-31 18:06  
老师,那个实验四的最后一个函数,就是“编写一个函数,能够求出坐标轴最右边的和最上边的点”,可是主函数注释给的却是“打印最右边的点”,有点不明白~
Re:C语言中数组名和指针的区别 溪边树 2010-03-30 14:52  
@龙杨 第二个(天气预报)和第三个实验(画板系统)。
Re:C语言中数组名和指针的区别 龙杨 2010-03-30 13:07  
老师,实验报告要求写哪个?
Re:实验1 -- 星座占卜标准答案 溪边树 2010-03-24 23:25  
@fzstar ^_^ 恭喜你,你答对了!
Re:实验1 -- 星座占卜标准答案 fzstar 2010-03-24 22:14  
思考题: 先按老师说的设计这个数组 int splitDay[] = {20, 19, 21,....} 判断部分: [code=cpp] if (day <= splitDay[month]) {   cout << "你的星座是:" << names[month] << endl; } else {   cout << "你的星座是:" << names[month+1] << endl; } [/code] 可能数组names中个星座名的排列顺序需要改一下。。 大体思路就是这样,可能在1月和12月的地方需要特别处理一下
Re:实验1 -- 星座占卜标准答案 溪边树 2010-03-19 20:56  
呵呵。给个提示:请设计以下数组 [code=cpp] int splitDay[] = {20, 19, 21,....} [/code] 分别表示1月,2月,3月至12月的分界线。
共2页: 1 2 下一页