Advertisement
eric11144

word_show_time_linked_list

Jan 12th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #include "push.h"
  6.  
  7. int main()
  8. {
  9. int count;
  10. int i;
  11. int size;
  12. char word;
  13.  
  14. printf("input the malloc size: ");
  15. scanf("%d", &size);
  16.  
  17. char *str = (char*)malloc(sizeof(char) * (size+1));
  18.  
  19. stack_node_t nodes;
  20. init(&nodes);
  21.  
  22. printf("you want to show the word and time\n");
  23. scanf("%s", str);
  24.  
  25. while(*str != '\0')
  26. {
  27. if(isalpha(*str))
  28. {
  29. word = *str;
  30. }
  31. else
  32. {
  33. count = atoi(str);
  34.  
  35. for(i = 0 ; i < count; i++)
  36. {
  37. stack_node_insert(&nodes, word);
  38. }
  39. }
  40.  
  41. str++;
  42. }
  43.  
  44. stack_printlist(&nodes);
  45.  
  46. stack_node_all_delete(&nodes);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement