Василина ♥Lina Куликова,вот код программы которую вы просили,но лучше все таки в аське меня поймайте,я файлы пришлю,да и спрашивать проще будет коль непонятно что-то..
вообщем так. Вот главный файл:
#include "stdafx.h"
#include "Defines.h"
#include <conio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
void _tmain()
{
int _variant=0;
cout<<"Hello,User!"<<endl;
cout<<"Programm started"<<endl<<endl;
cout<<"Please enter your variant:>";
cin>>_variant;
cout<<endl<<"Calculation last base of numbers.."<<endl;
int _base=CalcBase(_variant);
if(_base==-1)
{
cout<<"Wrong variant!"<<endl;
return;
}
cout<<"Last base of numbers="<<_base<<endl;
cout<<"Please enter address on your hard drive for text file that will be created(For example C:\\):>";
string _address="";
cin>>_address;
fstream _TFile;
_address+="\\_TFile.txt";
size_t i=0;
size_t Inp_size=strlen(_address.c_str())+1;
wchar_t _new_address[100];
mbstowcs_s(&i,_new_address,Inp_size,_address.c_str(),_TRUNC?1?T?1?);
_TFile.open(_new_address,ios_base:
ut|ios_base::trunc);
if(!_TFile.is_open())
{
cout<<"Wrong address!"<<endl;
return;
}
cout<<endl<<"Creating text file.."<<endl;
string _convertedNum="";
for(int current_num=1;current_num<=25;current_num++)
{
_TFile<<setw(25)<<right<<current_num;
_convertedNum=DecToANS(current_num,2);
_TFile<<setw(25)<<right<<_convertedNum;
_convertedNum=DecToANS(current_num,16);
_TFile<<setw(25)<<right<<_convertedNum;
_convertedNum=DecToANS(current_num,_base);
_TFile<<setw(25)<<right<<_convertedNum<<endl;
}
cout<<"Text file created"<<endl;
cout<<endl<<"Programmed by Lina"<<endl<<"Design by Lina"<<endl<<endl;
cout<<"Please press <Enter> for end the programm:>";
_getch();
}
А это дополнитеьный h-файл:
#include <stdlib.h>
#include <string>
#include <sstream>
using namespace std;
int CalcBase(const int Var) {
if((Var>300)||(Var<=0))
return -1;
int CBase=(Var%15)+10;
return CBase;
}
string FindSymbOfANS(const int digit) {
if((digit>29)||(digit<0))
exit(0);
string symbol="";
stringstream ConvertStream;
if(digit<10)
{
ConvertStream << digit;
ConvertStream >> symbol;
return symbol;
}
int CurDig=10;
char symb='A';
while(CurDig!=digit)
{
CurDig++;
symb++;
}
symbol=symb;
return symbol;
}
string DecToANS(int DecNum,const int BaseOfANS) {
if((BaseOfANS<2)||(BaseOfANS>24)||(DecNum<0)||(DecNum>1000000))
return "-1";
if(DecNum==0)
return "0";
int WholePart,Remainder;
WholePart=Remainder=0;
string CNum="";
while(De