Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3. int maxItems=15;
  4. int maxItemsTable[15];
  5. int numOfDisplays=6;
  6. int i;
  7. int counter=numOfDisplays;
  8. int choice;
  9. int temp=0;
  10. int x;
  11. for (i=0; i<maxItems; i++){
  12. maxItemsTable[i]=i;
  13. // printf("%d\n",maxItemsTable[i]);
  14. }
  15. while(1){
  16. if(numOfDisplays<=maxItems){
  17. for(i=temp; i<counter; i++){
  18. if(i>-1 && i<maxItems){
  19. printf("%d ",maxItemsTable[i]);
  20. }
  21. else if(i>=maxItems){
  22. printf("%d ",maxItemsTable[i-maxItems]);
  23. }
  24. else if(i<0){
  25. printf("%d ",maxItemsTable[maxItems+i]);
  26. }
  27. }
  28. printf("\n");
  29. scanf("%d",&choice);
  30. //gia choice=1 paei 6 mprosta
  31. if (choice==1){
  32. counter+=numOfDisplays;
  33. temp+=numOfDisplays;
  34. if(counter>maxItems){
  35. counter-=maxItems;
  36. temp-=maxItems;
  37. }
  38. }
  39. //gia choice=2 paei 6 pisw
  40. if (choice==2){
  41. counter-=numOfDisplays;
  42. temp-=numOfDisplays;
  43. if(counter<0){
  44. counter+=maxItems;
  45. temp+=maxItems;
  46. }
  47. }
  48. }
  49. else{
  50. for(i=temp; i<counter; i++){
  51. if(i<maxItems){
  52. printf("%d ",maxItemsTable[i]);
  53. }
  54. else{printf("-1");
  55. }
  56. }
  57. scanf("%d",&choice);
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement