Guest User

Untitled

a guest
Nov 29th, 2010
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<alloc.h>
  4. typedef struct pointer
  5. { int info;
  6. struct pointer *link;
  7. } ds;
  8. ds *l,*q,*p,*k;
  9. int a,n;
  10. void init()
  11. {
  12. l=NULL;
  13. }
  14. int ccs()
  15. {
  16. if(n<=2) return 0;
  17. p=l;
  18. q=l;
  19. p=p->link;
  20. k=p->link;
  21. while(k!=NULL)
  22. {
  23. if(p->info!=(q->info+k->info)/2) return 0;
  24. q=q->link;
  25. p=p->link;
  26. k=k->link;
  27. }
  28. return 1;
  29. }
  30. int tang()
  31. {
  32. q=l;p=l;
  33. p=p->link;
  34. while(p!=NULL)
  35. {
  36. if(q->info<p->info) return 0;
  37. q=q->link;
  38. p=p->link;
  39. }
  40. return 1;
  41. }
  42. main()
  43. {
  44. int i;
  45. init();
  46. printf("nhap tu ban phim so phan tu cua danh sach \n");
  47. printf("khuyen cao : nen nhap tu` 3 phan tu? tro len . \n N=");
  48. scanf("%d",&n);
  49. for(i=1;i<=n;i++)
  50. {
  51. p=(ds *)malloc(sizeof(ds));
  52. printf("phan tu thu %d ",i);
  53. scanf("%d",&p->info);
  54. p->link=l;
  55. l=p;
  56. }
  57. p=l;a=0;
  58. while(p!=NULL)
  59. {
  60. if(p->info>0) a++;
  61. p=p->link;
  62. }
  63. if(a==0) printf("danh sach khong co phan tu nao duong \n");
  64. else printf(" so phan tu duong co trong danh sach la :%d \n",a);
  65. if(ccs()==0) printf(" trong danh sach khong ton tai mot day so cap so cong \n ");
  66. else printf("danh sach ton tai mot day so cap so cong \n");
  67. if(tang()==0) printf("danh sach khong duoc sap sep tang \n");
  68. else printf("danh sach dc sap xep theo thu tu tang dan \n");
  69. getch();
  70. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×