Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int sost=1; char x;
- ifstream fin("f:\Text.txt");
- while (fin.peek() != EOF)
- {
- fin >> x;
- switch (sost)
- {
- case 1:
- {
- if ((x == '+') || (x == '-'))
- sost=2;
- else
- sost=0;
- break;
- }
- case 2:
- {
- if (x < '0' || x > '9')
- {
- if (x == '.')
- sost=3;
- else
- sost=0;
- }
- break;
- }
- case 3:
- {
- if (x < '0' || x > '9')
- {
- if (x == 'E' || x == 'e')
- sost=4;
- else
- sost=0;
- }
- break;
- }
- case 4:
- {
- if ((x == '+') || (x == '-'))
- sost=5;
- else
- sost=0;
- break;
- }
- case 5:
- {
- if (x < '0' || x > '9')
- sost=0;
- else sost=6;
- break;
- }
- case 6:
- {
- if (x < '0' || x > '9')
- sost=0;
- break;
- }
- }
- }
- if (sost==6)
- cout << "Запись числа верная" << endl;
- else
- cout << "Запись числа НЕ верная" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement