Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int count1 = 0, count2 = 0, count3 = 0, number = 0, flag = 0, counter = 0;
  6. char current , previous = 'c';
  7.  
  8. while ((current = getchar()) != '@')
  9. {
  10. printf("%c\n", current);
  11. if (('1' <= current) && (current <= '9'))
  12. {
  13. flag = 1;
  14. counter = 0;
  15. number = current - 48;
  16. }
  17. else
  18. {
  19. if ((('0' > previous) && (previous >= '9')) && flag ==1 && current-previous ==1)
  20. {
  21. counter++;
  22. }
  23. if ((('0' > previous) && (previous >= '9')) && current-previous !=1)
  24. {
  25. flag = 0;
  26. }
  27. printf("%d\n", flag);
  28.  
  29. if (('0' < previous) && (previous <= '9'))
  30. {
  31. counter = 1;
  32. }
  33. if ((counter == number) && (flag = 1))
  34. {
  35. count2 += number;
  36. count1++;
  37. }
  38. }
  39. previous = current;
  40. }
  41. printf("%d\n%d\n%d\n", count1, count2, count3);
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement