inch to sm



Автор Елена *** задал вопрос в разделе Другие языки и технологии

!!!Подскажите пожалуйста как в С++ разработать приложение (условие...)? и получил лучший ответ

Ответ от Николай Веселуха[гуру]
#include <iostream>#include <iomanip>#include <string>#include <Windows.h>#include <conio.h>#define INCH 2.54#define INDENT 5#define PRECISION 12using namespace std;void ini();void russian();void menu();void indent(short);void show();void from_sm_to_inch();void from_inch_to_sm();int main() { ini(); return 0;}void ini() { ::SetConsoleTitleW(L"Конвертор длин"); system("color 9B"); russian(); menu(); cin.sync(); cin.get();}inline void russian() { wcout.imbue(locale(".866")); wcin.imbue(locale(".866")); wcerr.imbue(locale(".866")); wclog.imbue(locale(".866"));}void menu() { enum points { ONE = '1', TWO = '2', ESC = 27 }; char choice; while (true) { system("cls"); show(); switch (choice = _getch()) { case ONE: from_sm_to_inch(); break; case TWO: from_inch_to_sm(); break; case ESC: exit(0); } }}void indent(short _w) { do cout << (' '); while (--_w); }void show() { const streamsize full = 80; wstring title(L"КОНВЕРТОР ДЛИН"); streamsize set_title = (full >> 1) + (title.size() >> 1); wcout << L'
' << setw(set_title) << title << L"

"; short idt = 11; indent(idt); wcout << L"Для перевода из сантиметров в дюймы нажмите клавишу 1
"; indent(idt); wcout << L"Для перевода из дюймов в сантиметры нажмите клавишу 2
"; indent(idt); wcout << L"Для выхода из программы нажмите клавишу Esc
"; indent(full >> 1);}void from_sm_to_inch() { cout << endl; short idt = INDENT; indent(idt); wcout << L"Введите сантиметры: "; double sm; cin >> sm; indent(idt); wcout << L"Результат: " ; cout << setprecision(PRECISION) << sm / INCH << "
"; indent(idt); system("pause");}void from_inch_to_sm() { cout << endl; short idt = INDENT; indent(idt); wcout << L"Введите дюймы: "; double inchs; cin >> inchs; indent(idt); wcout << L"Результат: "; cout << setprecision(PRECISION) << inchs * INCH << "
"; indent(idt); system("pause");}

Ответ от Nedovypendr2 Perenychij2[гуру]
все цикели взаимозаменяемы. . но они врятли помогут перевести дюймы в сантиметры..

Ответ от 3 ответа[гуру]
Привет! Вот подборка тем с похожими вопросами и ответами на Ваш вопрос: !!!Подскажите пожалуйста как в С++ разработать приложение (условие...)?
Дюйм на Википедии
Посмотрите статью на википедии про Дюйм
 

Ответить на вопрос:

Имя*

E-mail:*

Текст ответа:*
Проверочный код(введите 22):*