Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void main()
- {
- char s[7] = "+6.e-7";
- bool b = true;
- int q = 0;
- int i;
- for (i = 0; i < 6 && b; i++)
- {
- switch (q)
- {
- case 0: if (s[i] == '+' || s[i] == '-')
- q = 1;
- else b = false;
- break;
- case 1:
- if (s[i] <= '9'&& s[i] >= '0')
- q = 2;
- else b = false;
- break;
- case 2:
- if (s[i] <= '9'&& s[i] >= '0')
- q = 2;
- else
- {
- if (s[i] <= '.')
- q = 3;
- else b = false;
- }
- break;
- case 3:
- if (s[i] <= '9'&& s[i] >= '0')
- q = 4;
- else b = false;
- break;
- case 4:
- if (s[i] <= '9'&& s[i] >= '0')
- q = 4;
- else
- {
- if (s[i] == 'E' || s[i] == 'e')
- q = 5;
- else b = false;
- }
- break;
- case 5: if (s[i] == '+' || s[i] == '-')
- q = 6;
- else b = false;
- break;
- case 6:
- if (s[i] <= '9'&& s[i] >= '0')
- q = 7;
- else b = false;
- break;
- case 7: if (s[i] <= '9'&& s[i] >= '0')
- q = 7;
- else
- b = false;
- break;
- }
- }
- if (b && q == 7)
- cout << "Correctly"<<endl;
- else cout << "Incorrectly" << endl;
- system("pause");
- }
- #include <iostream>
- using namespace std;
- void main()
- {
- setlocale(LC_ALL, "Russian");
- int x[8] = { 8,7,6,5,4,3,2,1 };
- bool f1 = true;
- bool f2 = true;
- for (int i = 0; i < 7&&f1; i++)
- {
- if (x[i] >= x[i + 1]) f1 = false;
- }
- for (int i = 0; i < 7 && f2; i++)
- {
- if (x[i] <= x[i + 1]) f2 = false;
- }
- if (f1) cout << "упорядочен по возрастанию "<<endl;
- else if (!f2)cout<< "неупорядочен по возрастанию и неупорядочен по убыванию ";
- else cout << "упорядочен по убыванию ";
- system("pause");
- }
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- using namespace std;
- const int str = 12;
- const int st = 4;
- const int len = 44;
- const int n = 5;
- const int m = 4;
- void star1(int len,ofstream &f)
- {
- for (int i = 0; i < len; i++)
- f << '*';
- f << endl;
- }
- void star2(ifstream &f, ofstream &f2, int n1, int n2, int n3)// n1,n2- length of columns, n3 - quantity of columns
- {
- string s;
- f >> s;
- f2 << '*' << setw(n1) << s << "*";
- for (int i = 0; i < n3; i++)
- {
- f >> s;
- f2 << setw(n2) << s << " *";
- }
- f2 << endl;
- }
- int main()
- {
- ifstream in("Text.txt");
- ofstream out("Text1.txt");
- int **a = new int *[m];
- for (int i = 0; i < m; i++)
- a[i] = new int[n];
- for (int i = 0; i < m; i++)
- for (int j = 0; j < n; j++)
- in >> a[i][j];
- out << setw(26) << "Selling " << endl;
- star1(len,out);
- star2(in,out, str, st, n);
- star1(len, out);
- string s;
- for (int i = 0; i < m; i++)
- {
- in >> s;
- out << '*' <<std::left<< setw(str) << s << '*';
- for (int j = 0; j < n; j++)
- {
- out << setw(st) << std::right<< a[i][j] << " *";
- }
- out << endl;
- star1(len, out);
- }
- int sum[n];
- for (int i = 0; i < n; i++)
- sum[i] = 0;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- sum[i] = sum[i] + a[j][i];
- s = "total";
- out << '*' << setw(str) << std::left << s << '*';
- for (int j = 0; j < n; j++)
- {
- out << setw(st) << std::right << sum[j] << " *";
- }
- out << endl;
- star1(len, out);
- system("pause");
- return 0;
- }
- #include <iostream>
- #include <math.h>
- using namespace std;
- void print(int n)
- {
- if (n > 0)
- {
- print(n - 1);
- cout << n << ' ';
- }
- }
- int main()
- {
- int m;
- cin >> m;
- print(m);
- system("pause");
- return 0;
- }
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- string s;
- getline(cin, s);
- int n = s.length();
- int k = 0; int n1, n2=-1;
- bool f=true;
- for (int i = 1; i < n - 1; i++)
- {
- if (s[i-1] == ' ')
- {
- n1 = i;
- }
- if (s[i + 1] == ' ')
- {
- n2 = i;
- }
- if (s[i] == ' ') { f = true; n1 = 0; n2 = 0; }
- if (n1*n2>0)
- {
- for (int j = 0; j < (n2 - n1 + 1) / 2 && f; j++)
- {
- if (s[n1 + j] != s[n2 - j]) f = false;
- }
- if (f) k++;
- }
- }
- cout << k;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment