鱼C论坛

 找回密码
 立即注册
查看: 2286|回复: 0

C++一道程序题

[复制链接]
发表于 2014-10-17 10:14:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
【程序设计】
--------------------------------------------------

功能:输入两个个16进制数(4位以内),要求计算它们的16和,并返回计算结果
    编写函数fun,
    在main函数中由键盘输入表达式并输出运算结果。请编写fun函数。
    请合理利用其它函数,和数组
例如:1AB CD
输出278
------------------------------------------------*/ 希望大家帮忙解决一下{:1_1:}
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<string>
  4. #include<fstream>
  5. using namespace std;
  6. void wwjt();
  7. int hash(char ch)
  8. {
  9.     if (ch>='0' && ch<='9') return ch-'0';
  10.     if (ch>='A' && ch<='F') return ch-'A'+10;
  11.     return -1;
  12. }
  13. char reverse_hash[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  14. void deal(string &a,string &b)
  15. {
  16.     int len=max(a.length(),b.length())+1;
  17.     while (a.length()<len)a='0'+a;
  18.     while (b.length()<len) b='0'+b;
  19. }
  20. void recover(string &a)
  21. {
  22.     while (a[0]=='0' && a.length()) a.erase(0,1);
  23. }
  24. string  fun(const string&a,const string &b)
  25. {

  26.   /**********Program**********/
  27.   /**********  End  **********/
  28. }

  29. main()
  30. {
  31.   string  a,b;
  32.   string result;
  33.     cin>>a>>b;
  34.     result=fun(a,b);
  35.     cout<<result<<endl;
  36.   wwjt();
  37. }

  38. void wwjt()
  39. {
  40.     ifstream IN("c++05.in");
  41.     ofstream OUT("c++05.out");
  42.     string a,b;
  43.     string iOUT;
  44.     while (IN>>a>>b)
  45.     {
  46.     iOUT=fun(a,b);
  47.    // cout<<iOUT<<endl;
  48.     OUT<<iOUT<<endl;
  49.     }

  50. }
复制代码




小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-3 12:37

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表