Advertisement
Qellex

af

Apr 1st, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int zif(char* str, char* dlina, int i) {
  6.     char zif[] = { '1', '2','3','4','5','6','7','8','9','0' };
  7.     for (int j = 0; j < dlina-1; j++) {
  8.         char* zife1 = strchr(zif, str[j]);
  9.         char* zife2 = strchr(zif, str[j + 1]);
  10.         if ((!(zife1)) && (!(zife2)))
  11.             return 1;
  12.     }
  13.     return 0;
  14. }
  15.  
  16. int main() {
  17.  
  18.     char str[81],
  19.         zn[] = { '+','-','/','*' };
  20.  
  21.     SetConsoleCP(1251);     SetConsoleOutputCP(1251);
  22.  
  23.     printf("Введите предложение: ");
  24.     fgets(str, 81, stdin);
  25.     int len = strlen(str) - 1;
  26.     int stats = 0;
  27.    
  28.     for (int i = 0; str[i] != '\0'; i++) {
  29.         char* znak = strchr(zn, str[i]);
  30.         int zna = znak;
  31.         if (zif(str, zna, i)) {
  32.             printf("Неверно");
  33.             return 0;
  34.         }
  35.         i += zna;
  36.  
  37.  
  38.  
  39.     }
  40.  
  41.     system("pause");
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement