MAKEBAR.CPP
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:1k
源码类别:

Windows编程

开发平台:

Visual C++

  1. #include<graphics.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. int READ_NUM(void);
  5. int READ_HIGHT(int ID);
  6. void main()
  7. {
  8. int NUM,I,VALUE[50];
  9. int driver=DETECT,mode;
  10. registerbgidriver(EGAVGA_driver);
  11. initgraph(&driver,&mode,"");
  12. NUM=READ_NUM();
  13. for(I=1;I<=NUM;I++)
  14. VALUE[I]=READ_HIGHT(I);
  15. setcolor(WHITE);
  16. line(0,400,639,400);
  17. setcolor(YELLOW);
  18. setfillstyle(1,BLUE);
  19. for(I=1;I<=NUM;I++)
  20. bar3d(I*10,400-VALUE[I],(I+1)*10,400,10,1);
  21. getch();
  22. closegraph();
  23. }
  24. int READ_NUM(void)
  25. {
  26. int NUM;
  27. do
  28. {
  29. printf("Input the NUM(1-50):");
  30. scanf("%d",&NUM);
  31. }while((NUM>50)|(NUM<0));
  32. return(NUM);
  33. }
  34. int READ_HIGHT(int ID)
  35. {
  36. int NUM;
  37. do
  38. {
  39. printf("Input the VALUE[%d](1-400):");
  40. scanf("%d",&NUM);
  41. }while((NUM<1)|(NUM>400));
  42. return(NUM);
  43. }