fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. char str[51];
  7. int i, cont_char;
  8. int negrito, italico;
  9.  
  10. while ((scanf(" %50[^\n]", str)) != EOF)
  11. {
  12. italico = 0;
  13. negrito = 0;
  14. cont_char = strlen(str);
  15. for (i = 0; i < cont_char; i++)
  16. {
  17. if (str[i] == '_')
  18. {
  19. if (italico % 2 == 0)
  20. {
  21. printf("<i>");
  22. }
  23. else
  24. {
  25. printf("</i>");
  26. }
  27. italico++;
  28. }
  29. else if (str[i] == '*')
  30. {
  31. if (negrito % 2 == 0)
  32. {
  33. printf("<b>");
  34. }
  35. else
  36. {
  37. printf("</b>");
  38. }
  39. negrito++;
  40. }
  41. else
  42. {
  43. printf("%c", str[i]);
  44. }
  45. }
  46. printf("\n");
  47. }
  48. return 0;
  49. }
Success #stdin #stdout 0s 5296KB
stdin
You _should_ see the new walrus at the zoo!
Move it from *Accounts Payable* to *Receiving*.
I saw _Chelydra serpentina_ in *Centennial Park*.
_ _ __ _ yabba dabba _ * dooooo * ****
_now_I_know_*my*_ABC_next_time_*sing*it_with_me
stdout
You <i>should</i> see the new walrus at the zoo!
Move it from <b>Accounts Payable</b> to <b>Receiving</b>.
I saw <i>Chelydra serpentina</i> in <b>Centennial Park</b>.
<i> </i> <i></i> <i> yabba dabba </i> <b> dooooo </b> <b></b><b></b>
<i>now</i>I<i>know</i><b>my</b><i>ABC</i>next<i>time</i><b>sing</b>it<i>with</i>me