fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. struct sdp{
  6.  
  7. int num;
  8.  
  9. struct sdp *ps;
  10. struct sdp *pd;
  11.  
  12.  
  13. };
  14.  
  15. struct sdp* fcl(int ns);
  16.  
  17.  
  18.  
  19. int main(void) {
  20. // your code goes here
  21. return 0;
  22. }
  23.  
  24.  
  25.  
  26. struct sdp* fcl(int ns){
  27.  
  28. struct sdp *ps1,*ps2;
  29.  
  30. ps1=(struct sdp*)malloc(sizeof(struct sdp));
  31.  
  32. ps1->num=ns;
  33.  
  34. ps1->pd=NULL;
  35.  
  36. while(ns>1){
  37.  
  38. ns--;
  39.  
  40. ps2=(struct sdp*)malloc(sizeof(struct sdp));
  41.  
  42. ps1->ps=ps2;
  43.  
  44. ps2->pd=ps1;
  45.  
  46. ps1=ps2;
  47.  
  48. }
  49.  
  50. ps1->ps=NULL;
  51.  
  52. return ps1;
  53.  
  54. }
  55.  
  56.  
  57. void fs(struct sdp *pst){
  58.  
  59.  
  60. while(pst!=NULL){
  61.  
  62. printf("%d\n",pst->num);
  63. printf("%d\n",pst->ps);
  64. printf("%d\n",pst->pd);
  65. printf("%d\n",pst);
  66.  
  67. pst=pst->pd;
  68.  
  69. }
  70.  
  71.  
  72.  
  73. }
  74.  
  75.  
Success #stdin #stdout 0s 5412KB
stdin
Standard input is empty
stdout
Standard output is empty