|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
【程序设计】
--------------------------------------------------
功能:输入两个个16进制数(4位以内),要求计算它们的16和,并返回计算结果
编写函数fun,
在main函数中由键盘输入表达式并输出运算结果。请编写fun函数。
请合理利用其它函数,和数组
例如:1AB CD
输出278
------------------------------------------------*/ 希望大家帮忙解决一下{:1_1:}
- #include<iostream>
- #include<cstdio>
- #include<string>
- #include<fstream>
- using namespace std;
- void wwjt();
- int hash(char ch)
- {
- if (ch>='0' && ch<='9') return ch-'0';
- if (ch>='A' && ch<='F') return ch-'A'+10;
- return -1;
- }
- char reverse_hash[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
- void deal(string &a,string &b)
- {
- int len=max(a.length(),b.length())+1;
- while (a.length()<len)a='0'+a;
- while (b.length()<len) b='0'+b;
- }
- void recover(string &a)
- {
- while (a[0]=='0' && a.length()) a.erase(0,1);
- }
- string fun(const string&a,const string &b)
- {
- /**********Program**********/
- /********** End **********/
- }
- main()
- {
- string a,b;
- string result;
- cin>>a>>b;
- result=fun(a,b);
- cout<<result<<endl;
- wwjt();
- }
- void wwjt()
- {
- ifstream IN("c++05.in");
- ofstream OUT("c++05.out");
- string a,b;
- string iOUT;
- while (IN>>a>>b)
- {
- iOUT=fun(a,b);
- // cout<<iOUT<<endl;
- OUT<<iOUT<<endl;
- }
- }
复制代码
|
|