请问各路高手几个关于几个C语言的问题。感激不尽!!!

设计一个程序,用链表的方式对某一群人的幸运数字进行集中管理,具有:分析,统计,打印,添加,删除,修改,查询的功能(请在此处添加你的设计源程序及必要的运行结果)<要截图>;... 设计一个程序,用链表的方式对某一群人的幸运数字进行集中管理,具有:分析,统计,打印,添加,删除,修改,查询的功能(请在此处添加你的设计源程序及必要的运行结果)<要截图>;
2、设计一个程序,要求能打开一个指定的24为彩色BMP图像文件,将该图像数据部分每个像素BGR3个分量的值进行简单的运行后形成一个新B'G'R',最后生成一个新图像文件(黑白)。也要运行结果截图
展开
 我来答
chenyuanhuiwan
2011-01-02 · TA获得超过591个赞
知道小有建树答主
回答量:434
采纳率:0%
帮助的人:295万
展开全部

#include <iostream>

#include <string>

using namespace std;

class LuckyNumber  //幸运者类

{

public:

 LuckyNumber();

 int  Total();//构造函数

 void Display();//打印

 bool Insert(const int& value, const string& name);//添加

 bool Delete(const int& number);//根据幸运者数字删除

 bool Modification(const string& name, const int& number);//修改

 string Inquires(const int& number);//根据幸运者数字查询姓名

 int  Inquires(const string& name);//根据幸运者姓名查询号码

private:

 string name;//幸运者姓名

 int  number;//幸运者号码

 LuckyNumber* next;//连接下一个节点

 

};

LuckyNumber::LuckyNumber()

{

 this ->next = NULL;

 this ->name = "头节点";

 this ->number = 0;

}

int LuckyNumber::Total()

{

 int count = 0;

 LuckyNumber* current = this ->next;

 while(current != NULL)

 {

  count++;

  current = current ->next;

 }

 cout<<"幸运者总数:"<<count<<endl;

 return count;

}

void LuckyNumber::Display()

{

 if (0 == Total())

 {

  cout<<"无幸运者!"<<endl;

  return ;

 }

 LuckyNumber* current = this ->next;

 while(current != NULL)

 {

  cout<<"幸运者姓名:"<<current->name<<",幸运数字:"<<current->number<<endl;

  current = current ->next;

 }

 return ;

}

bool LuckyNumber::Insert(const int& value, const string& name)//为方便起见,将新增幸运者加入到头结点后面

{

 LuckyNumber* temp = new LuckyNumber;

 temp ->name = name;

 temp ->number = value;

 temp ->next = this ->next;

 this ->next = temp;

 cout<<"幸运者 "<<name<<" 被成功添加!"<<endl;

 return true;

}

bool LuckyNumber::Delete(const int& number)

{

 if (0 == Total())

 {

  cout<<"已无幸运者!"<<endl;

  return false;

 }

 LuckyNumber* current = this ->next;

 LuckyNumber* temp = this;

 while(current != NULL)

 {

  if(current ->number == number)

  {

   temp ->next = current ->next;

   delete current;

   cout<<"幸运数字为 "<<number<<" 的幸运者被成功删除!"<<endl;

   return true;

  }

  else

  {

   current = current ->next;

   temp = temp ->next;

  }

 }

 cout<<"无此幸运数字!"<<endl;

 return false;

}

bool LuckyNumber::Modification(const string& name, const int& number)

{

 LuckyNumber* current = this ->next;

 while(current != NULL)

 {

  if (current ->name == name)

  {

   current ->number = number;

   cout<<"幸运者 "<<name<<" 的幸运数字已成功更改!"<<endl;

   return true;

  }

  else

   current = current ->next;

 }

 cout<<"查无此人!"<<endl;

 return false;

}

int  LuckyNumber::Inquires(const string& name)

{

 if (Total() == 0)

 {

  cout<<"无幸运者!"<<endl;

  return false;

 }

 LuckyNumber* current = this ->next;

 while(current != NULL)

 {

  if (current ->name == name)

   return current ->number;

  else

   current = current ->next;

 }

 cout<<"查无此人"<<endl;

 return -1;

}

string LuckyNumber::Inquires(const int& number)

{

 if (Total() == 0)

  return "无幸运者";

 LuckyNumber* current = this ->next;

 while(current != NULL)

 {

  if (current ->number == number)

   return current ->name;

  else

   current = current ->next;

 }

 return "查无此号!";

}

int main()

{

 LuckyNumber person;

 person.Insert(10001, "张三");

 person.Insert(10002, "李四");

 person.Insert(10003, "王五");

 person.Display();

 person.Delete(10001);

 person.Display();

 /*

 ……

 里面可以自己写代码测试,我就不写了哈!写代码好辛苦啊,楼主追加点分吧,第二个题还在做,先把第一个发上来再说哦

 ……

 ……

 */

 return 0;

}

匿名用户
2010-12-30
展开全部
帮顶 我也初学者
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式