daniel_0247
چهارشنبه 11 اسفند 1389, 09:57 صبح
سلام به تمامی دوستان ، این کد به زبان ++C هستش ، اگر کمکی کنید ، میخوان این رو به C تبدیل کنم ، چطور syntax رو عوض کنم ؟؟
#include <iostream>
#include <string>
#include <strstreamtream>
using namespace std;
string MyDecConvertHex(long a);
long MyHexConvertDec(const string & hexstr);
string MyAddHex(const string & FHex, const string & SHex);
string MyAddSub(const string & FHex, const string & SHex);
void main()
{
string FHex, SHex;
cout << endl << "Enter Your Numbers: " << endl << endl;
cout << "First Hex Number: ";
cin >> FHex;
cout << "Second Hex Number: ";
cin >> SHex;
cout << "Sum Is: " << MyAddSub(FHex,SHex) << endl;
cin >> FHex;
}
string MyAddHex(const string & FHex, const string & SHex)
{
long x1, x2;
x1 = MyHexConvertDec(FHex);
x2 = MyHexConvertDec(SHex);
return MyDecConvertHex(x1+x2);
}
string MyAddSub(const string & FHex, const string & SHex)
{
long x1, x2;
x1 = MyHexConvertDec(FHex);
x2 = MyHexConvertDec(SHex);
return MyDecConvertHex(x1-x2);
}
string MyDecConvertHex(long i)
{
stringstream strstream;
string str;
hex(strstream);
uppercase(strstream);
strstream << i;
strstream >> str;
return str;
}
long MyHexConvertDec(const string & hexstr)
{
stringstream strstream;
long i = 0;
hex(strstream);
strstream << hexstr;
strstream.clear();
strstream >> i;
return i;
}
#include <iostream>
#include <string>
#include <strstreamtream>
using namespace std;
string MyDecConvertHex(long a);
long MyHexConvertDec(const string & hexstr);
string MyAddHex(const string & FHex, const string & SHex);
string MyAddSub(const string & FHex, const string & SHex);
void main()
{
string FHex, SHex;
cout << endl << "Enter Your Numbers: " << endl << endl;
cout << "First Hex Number: ";
cin >> FHex;
cout << "Second Hex Number: ";
cin >> SHex;
cout << "Sum Is: " << MyAddSub(FHex,SHex) << endl;
cin >> FHex;
}
string MyAddHex(const string & FHex, const string & SHex)
{
long x1, x2;
x1 = MyHexConvertDec(FHex);
x2 = MyHexConvertDec(SHex);
return MyDecConvertHex(x1+x2);
}
string MyAddSub(const string & FHex, const string & SHex)
{
long x1, x2;
x1 = MyHexConvertDec(FHex);
x2 = MyHexConvertDec(SHex);
return MyDecConvertHex(x1-x2);
}
string MyDecConvertHex(long i)
{
stringstream strstream;
string str;
hex(strstream);
uppercase(strstream);
strstream << i;
strstream >> str;
return str;
}
long MyHexConvertDec(const string & hexstr)
{
stringstream strstream;
long i = 0;
hex(strstream);
strstream << hexstr;
strstream.clear();
strstream >> i;
return i;
}