Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int q = 1;
- char x;
- ifstream f("Text2.txt");
- while ((f.peek() != EOF) && q)
- {
- f >> x;
- switch (q)
- {
- case 1: {
- if ((x == '+') || (x == '-'))
- q = 2;
- else
- q = 0;
- break;
- }
- case 2: {
- if (!(x >= '0' && x <= '9'))
- {
- if (x == '.')
- q = 3;
- else
- q = 0;
- }
- break;
- }
- case 3: {
- if (!(x >= '0' && x <= '9'))
- {
- if (x == 'E' || x == 'e')
- q = 4;
- else
- q = 0;
- }
- break;
- }
- case 4: {
- if ((x == '+') || (x == '-'))
- q = 5;
- else
- q = 0;
- break;
- }
- case 5: {
- if (!(x >= '0' && x <= '9'))
- q = 0;
- else q = 6;
- break;
- }
- case 6: {
- if (!(x >= '0' && x <= '9'))
- q = 0;
- break;
- }
- }
- }
- if (q == 6)
- cout << "YEeES" << endl;
- else
- cout << "NO" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment