Пишу на на Dev-C++(
OC :Windows Vista Ultimate SP1.
А то надоело писать
Код:
Код: Выделить всё
Vvedite symmy 4isel, хотелось бы
Код:
Код: Выделить всё
Введите сумму чиселКод: Выделить всё
Vvedite symmy 4iselКод: Выделить всё
Введите сумму чисел
Код: Выделить всё
// Привет мир программирования, приветствие.
#include
#include
#include "russian.h"
void main()
{
coutКод: Выделить всё
/* #include можно удалить эту строку из "russian.h" */
#include
char* Rus(const char* text);
char bufRus[256];
char* Rus(const char* text)
{
CharToOem(text, bufRus);
return bufRus;
}Код: Выделить всё
//файл CyrIOS.h
#ifndef CYR_IOS_H
#define CYR_IOS_H
#include <iostream>
#include <iomanip>
#include <string>
#include <windows.h>
using namespace std;
#define MAX_STR_LEN 4096
//////////////////////////////////////////////////////////////////////////////////
// Класс CyrOstream
class CyrOstream : public ostream {
public:
CyrOstream(_Uninitialized no_init) : ostream(no_init) {};
CyrOstream& operator <<(_Myt& (_cdecl *_f)(_Myt&));
CyrOstream& operator <<(ios_base& (_cdecl *_f)(ios_base& ));
CyrOstream& operator <<(short n) { cout << n; return *this; }
CyrOstream& operator <<(unsigned short n){ cout << n; return *this; }
CyrOstream& operator <<(int n) { cout << n; return *this; }
CyrOstream& operator <<(unsigned int n){ cout << n; return *this; }
CyrOstream& operator <<(long n) { cout << n; return *this; }
CyrOstream& operator <<(unsigned long n) { cout << n; return *this; }
CyrOstream& operator <<(float f) { cout << f; return *this; }
CyrOstream& operator <<(double f) { cout << f; return *this; }
CyrOstream& operator <<(long double f) { cout << f; return *this; }
CyrOstream& operator <<(const void* v) { cout << v; return *this; }
CyrOstream& operator <<(const char*);
CyrOstream& operator <<(const unsigned char* s) { operator <<((const char*)s); return *this; }
CyrOstream& operator <<(const signed char* s) { operator <<((const char*)s); return *this; }
CyrOstream& operator <<(char);
CyrOstream& operator <<(unsigned char);
CyrOstream& operator <<(signed char c) { operator <<((char)c); return *this; }
CyrOstream& put(char);
CyrOstream& write(const char*, int);
CyrOstream& write(const unsigned char* s, int len)
{
write((const char*)s, len); return *this;
}
// Замещение методов класса ios
long setf(long lFlags) { return cout.setf(lFlags); }
void unsetf(long lFlags) { cout.unsetf(lFlags); }
char fill(char cFill) { return cout.fill(cFill); }
char fill() { return cout.fill(); }
int precision(int np) { return cout.precision(np); }
int precision() const { return cout.precision(); }
int width(int nw) { return cout.width(nw); }
int width() const { return cout.width(); }
int rdstate() const { return cout.rdstate(); }
long flags() const { return cout.flags(); }
long flags(long _l) { return cout.flags(_l); }
streambuf* rdbuf() const { return cout.rdbuf(); }
// Дружественная функция для поддержки параметризованных манипуляторов
friend CyrOstream& operator <<(CyrOstream&, const _Smanip<int>&);
private:
char buf_[MAX_STR_LEN];
};
////////////////////////////////
// Шаблон для вывода типа string
template<class _E, class _Tr, class _A>
inline CyrOstream& operator <<(CyrOstream& os, const basic_string<_E, _Tr, _A>& _X)
{
string temp(_X);
unsigned char symb[2];
symb[1] = 0;
for (int i = 0; i < temp.size(); i++)
{
symb[0] = temp.at(i);
if (symb[0] > 191)
CharToOem((const char*)symb, (char*)symb);
cout << symb;
}
return os;
}
///////////////////////////////////////////////////////////
// Класс CyrIstream
class CyrIstream : public istream {
public:
CyrIstream(_Uninitialized no_init) : istream(no_init) {};
CyrIstream& operator >>(ios_base& (_cdecl *_f)(ios_base& ));
CyrIstream& operator >>(char*);
CyrIstream& operator >>(unsigned char* s)
{
operator >>((char*)s); return *this;
}
CyrIstream& operator >>(signed char* s)
{
operator >>((char*)s); return *this;
}
CyrIstream& operator >>(char& c);
CyrIstream& operator >>(unsigned char& c)
{
operator >>((char&)c); return *this;
}
CyrIstream& operator >>(signed char& c)
{
operator >>((char&)c); return *this;
}
CyrIstream& operator >>(short &n) { cin >> n; return *this; }
CyrIstream& operator >>(unsigned short &n)
{
cin >> n; return *this;
}
CyrIstream& operator >>(int &n) { cin >> n; return *this; }
CyrIstream& operator >>(unsigned int &n)
{
cin >> n; return *this;
}
CyrIstream& operator >>(long &n) { cin >> n; return *this; }
CyrIstream& operator >>(unsigned long &n)
{
cin >> n; return *this;
}
CyrIstream& operator >>(float &f) { cin >> f; return *this; }
CyrIstream& operator >>(double &f) { cin >> f; return *this; }
CyrIstream& operator >>(long double &f)
{
cin >> f; return *this;
}
int get() { return cin.get(); }
CyrIstream& get(char&);
CyrIstream& get(char*, int, char='\n');
CyrIstream& get(unsigned char*, int, char = '\n');
CyrIstream& getline(char*, int, char='\n');
CyrIstream& getline(unsigned char* pch, int nCount, char delim ='\n')
{
getline((char*)pch, nCount, delim); return *this;
}
CyrIstream& read(char*, int);
CyrIstream& read(unsigned char* pch, int nCount)
{
read((char*)pch, nCount); return *this;
}
CyrIstream& ignore(int nCount = 1, int delim = EOF)
{
cin.ignore(nCount, delim); return *this;
}
int peek() { return cin.peek(); }
int gcount() const { return cin.gcount(); }
CyrIstream& putback(char ch) { cin.putback(ch); return *this; }
// Замещение методов класса ios
void clear(int nState = 0) { cin.clear(nState); }
long setf(long lFlags) { return cin.setf(lFlags); }
void unsetf(long lFlags) { cin.unsetf(lFlags); }
int rdstate() const { return cin.rdstate(); }
long flags() const { return cin.flags(); }
streambuf* rdbuf() const { return cin.rdbuf(); }
// Дружественная функция для поддержки параметризованных манипуляторов
friend CyrIstream& operator >>(CyrIstream&, const _Smanip<int>&);
private:
char buf_[MAX_STR_LEN];
};
/////////////////////////////////////////////////////////////
//Шаблон для ввода типа string
template<class _E, class _Tr, class _A>
inline CyrIstream& operator >>(CyrIstream& is, basic_string<_E, _Tr, _A>& _X)
{
string temp;
cin >> temp;
unsigned int n = temp.size();
char *buf = new char[n+1];
temp.copy(buf, n); buf[n] = 0;
OemToChar(buf, (char*)buf);
_X = string(buf);
delete [] buf;
return is;
}
CyrOstream& CyrOstream::operator << (_Myt& (_cdecl *_f)(_Myt&))
{
cout << _f; return *this;
}
CyrOstream& CyrOstream::operator << (ios_base& (_cdecl *_f)(ios_base& ))
{
cout << _f; return *this;
}
CyrOstream& CyrOstream::operator <<(const char *s)
{
int n = strlen(s);
strncpy(buf_, s, n); buf_[n] = 0;
CharToOem(buf_, buf_);
cout << buf_;
return *this;
}
CyrOstream& CyrOstream::operator <<(char c)
{
buf_[0] = c; buf_[1] = 0;
CharToOem(buf_, buf_);
cout << buf_;
return *this;
}
CyrOstream& CyrOstream::operator <<(unsigned char c)
{
unsigned char buf[2];
buf[0] = c; buf[1] = 0;
if (c > 191)
CharToOem((const char*)buf, (char*)buf);
cout << buf;
return *this;
}
CyrOstream& CyrOstream::put(char c)
{
buf_[0] = c; buf_[1] = 0;
CharToOem(buf_, buf_);
cout.put(buf_[0]);
return *this;
}
CyrOstream& CyrOstream::write(const char* s, int len)
{
int n = strlen(s);
strncpy(buf_, s, n); buf_[n] = 0;
CharToOem(buf_, buf_);
cout.write(buf_, len);
return *this;
}
CyrOstream& operator <<(CyrOstream& os, const _Smanip<int>& m)
{
cout << m; return os;
}
CyrIstream& CyrIstream::operator >> (ios_base& (_cdecl *_f)(ios_base& ))
{
cin >> _f; return *this;
}
CyrIstream& CyrIstream::operator >>(char* s)
{
string temp;
cin >> temp;
unsigned int n = temp.size();
temp.copy(buf_, n); buf_[n] = 0;
OemToChar(buf_, buf_);
strncpy (s, buf_, n + 1);
return *this;
}
CyrIstream& CyrIstream::operator >>(char& c)
{
cin >> buf_[0];
buf_[1] = 0;
OemToChar(buf_, buf_);
c = buf_[0];
return *this;
}
CyrIstream& CyrIstream::get(char& symb)
{
cin.get(buf_[0]);
buf_[1] = 0;
OemToChar(buf_, buf_);
symb = buf_[0];
return *this;
}
CyrIstream& CyrIstream::get(char* pch, int nCount, char delim)
{
cin.get(pch, nCount, delim);
OemToChar(pch, pch);
return *this;
}
CyrIstream& CyrIstream::get(unsigned char* pch, int nCount, char delim)
{
cin.get((char*)pch, nCount, delim);
OemToChar((const char*)pch, (char*)pch);
return *this;
}
CyrIstream& CyrIstream::getline(char* pch, int nCount, char delim)
{
cin.getline(pch, nCount, delim);
OemToChar(pch, pch);
return *this;
}
CyrIstream& CyrIstream::read(char* pch, int nCount)
{
cin.read(buf_, nCount);
buf_[nCount] = 0;
OemToChar(buf_, buf_);
for(int i = 0; i < nCount; i++)
pch[i] = buf_[i];
return *this;
}
CyrIstream& operator >>(CyrIstream& is, const _Smanip<int>& m)
{
cin >> m; return is;
}
//////////////////////////////////////////////////////////
// Глобальные объекты для ввода и вывода
CyrIstream Cin(_Noinit);
CyrOstream Cout(_Noinit);
///////////////////////////////////////////////////////////
extern CyrIstream Cin;
extern CyrOstream Cout;
#endif
#ifndef CYR_IOS_IMPLEMENTATION
#define cin Cin
#define cout Cout
#define istream CyrIstream
#define ostream CyrOstream
#endifКод: Выделить всё
#include "CyrIOS.h" //смотря как назовёте
using namespace std;
int main()
{
char str[100];
string a = "Привет мир С++";
cout << "Привет мир С++" << endl;
cin.getline(str, 100);
cout << str;
cout a;
return 0;
}