Advertisement
Guest User

Untitled

a guest
Nov 28th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <ctype.h>
  6.  
  7. int main()
  8. {
  9. RusPrint(); // Русские буквы
  10.  
  11. char Text[128]= "0abcde 12 fghi239jklmn 1 opqr20stuvw 509 xyz 34 ";
  12.  
  13. int Num= 0; int coef= 1; int sum=0;
  14.  
  15. for (int a= strlen(Text)-1; a>-1; a--)
  16. {
  17. if (isdigit(Text[a])) { Num= Num+(Text[a]-48)*coef; coef*=10; }
  18. else { coef= 1; sum+= Num; Num= 0; }
  19. }
  20.  
  21. printf("%s\n", Text);
  22. printf("\nСумма должна быть= 815, а получилось %d\n", sum);
  23. system("pause");
  24.  
  25. return 0;
  26. }
  27. //////////
  28. void RusPrint(void)
  29. {
  30. //Руссификация сообщений
  31.  
  32. SetConsoleOutputCP(1251);
  33. SetConsoleCP(1251);
  34.  
  35. SetConsoleTitle("ОтветыМейлРу");
  36.  
  37. return;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement