Untitled


SUBMITTED BY: Guest

DATE: Sept. 30, 2014, 10:19 p.m.

FORMAT: Text only

SIZE: 610 Bytes

HITS: 1239

  1. char letter='0';
  2. int openab=0;
  3. int openabnoc=0;
  4. int openacb=0;
  5. int sumab=0;
  6. int sumabnoc=0;
  7. int sumacb=0;
  8. int i;
  9. scanf("%c",&letter);
  10. while(letter!='.')
  11. {
  12. if(letter=='a')
  13. {
  14. openab++;
  15. openabnoc++;
  16. }
  17. if(letter=='c'&&openabnoc!=0)
  18. {
  19. openabnoc--;
  20. openacb++;
  21. }
  22. if(letter=='b'&&openabnoc!=0)
  23. {
  24. sumabnoc++;
  25. }
  26. if(letter=='b'&&openab!=0)
  27. {
  28. for(i=1;i<=openab;i++)
  29. {
  30. sumab++;
  31. }
  32. }
  33. if(letter=='b'&&openacb!=0)
  34. {
  35. sumacb++;
  36. }

comments powered by Disqus