Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
В наше время все большее внимание уделяется умственному развитию человека. Все больше людей хотят стать, к примеру, программистами. Большинство не справляется с этой задачей из-за отсутствия способности к выбору правильного метода решения задачи, а следовательно, вытекающими проблемами с написанием программного кода.
std::ofstream f("data.bin", std::ios::out);
std::ofstream f("data.bin", std::ios::binary | std::ios::out);
std::ofstream f("data.bin", std::ios::binary | std::ios::in | std::ios::out | std::ios::ate);
if (!f.is_open())
{
f.clear();
f.open("data.bin", std::ios::binary | std::ios::out | std::ios::trunc);
}
a = a ^ b; //1
b = b ^ a; //5
a = a ^ b; //4
- using System;
- using System.IO;
- using System.Text;
-
- namespace SimpleSTDNumericWrite
- {
- class Program
- {
- [STAThread]
- static void Main(string[] args)
- {
- Console.WriteLine("Hello! Write Numbers Please. To apply - press Enter key");
- Console.WriteLine("Double and Decimal could contains ',' , not '.' as separator");
- Console.WriteLine("To Exit Print 'exit' and press Enter");
- Console.WriteLine(Environment.NewLine);
-
- StartReadingFromConsole();
- }
-
- static void StartReadingFromConsole()
- {
- using (StreamWriter sw = new StreamWriter("file.txt", true, Encoding.ASCII))
- {
- string CurrentWordFromUser;
- do
- {
- CurrentWordFromUser = Console.ReadLine();
-
- if(isNumeric(CurrentWordFromUser))
- {
- Console.WriteLine("Added new Number");
- sw.WriteLine(CurrentWordFromUser);
- }
- else
- {
- Console.WriteLine("It is Not a Number");
- }
- }
- while (CurrentWordFromUser != "exit");
- }
- }
- static bool isNumeric(string val)
- {
- Decimal resultDecimal;
- if (Decimal.TryParse(val, out resultDecimal)) return true;
-
- Double resultDouble;
- if (Double.TryParse(val, out resultDouble)) return true;
-
- Single resultSingle;
- if (Single.TryParse(val, out resultSingle)) return true;
-
- Int32 resultInt32;
- return Int32.TryParse(val, out resultInt32);
- }
- }
- }
* This source code was highlighted with Source Code Highlighter.
И что же это такое?