Advertisement
Guest User

Untitled

a guest
Oct 18th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <conio.h>
  6. #include <windows.h>
  7. #include <locale.h>
  8. #include <ctype.h>
  9. #include <iostream>
  10. #define N 100
  11. void main()
  12. {
  13. SetConsoleCP(1251);
  14. SetConsoleOutputCP(1251);
  15. setlocale(0,"");
  16. char s[N], z[]="-*+/", c[]="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM",
  17. b[]="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
  18. int i,k=0;
  19. printf("Введите выражение=>");
  20. gets(s);
  21. /*Начало блока проверки знаков*/
  22. for( i=0; i<strlen(s); i++)
  23. {
  24. for(int j=0; j<strlen(z); j++)
  25. {
  26. if( (s[i]==z[j])&&(s[i+1]==z[j]) || ((s[i]==z[j])&&(i==0)&&(j!=0)) || (s[i]==z[j])&&(i==strlen(s)-1) ) k++;
  27. /*for(int p=0; p<strlen(c); p++)
  28. {
  29. if( ( (s[i]==z[j])&&(s[i+1]==c[p]) ) ) k++;
  30. }*/
  31. }
  32. }
  33. /*Конец блока проверки знаков*/
  34. /*Начало блока проверки буквенных выраженний*/
  35. for( i=0; i<strlen(s); i++)
  36. {
  37. for(int j=0; j<strlen(c); j++)
  38. {
  39. if( ( (s[i]==b[j])&&(s[i+1]==b[j]) ) ) k++;
  40.  
  41. }
  42. }
  43. /*конец блока проверки буквенных выраженний*/
  44. printf("%i",k);
  45. if (k>0) printf("Выражение неверно");
  46. else printf("Выражение верно");
  47. _getch();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement