wiley_pastebin

Question 25

Apr 11th, 2019
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. struct WeirdList{
  3.     int head;
  4.     int a[10];
  5. };
  6. struct WeirdList w;
  7.  
  8. void _add(int n){
  9.     w.a[w.head] = n;
  10.     w.head++;
  11. }
  12.  
  13. void _remove(){
  14.     w.head--;
  15. }
  16.  
  17. void p(){
  18.     for(int i=0; i<=10; i++){
  19.         printf("%d, ", w.a[i]);
  20.     }
  21. }
  22. int main(void) {
  23.     w.head = 0;
  24.     _add(3);
  25.     _add(4);
  26.     _remove();
  27.     _remove();
  28.     _add(1);
  29.     p();
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment