Guest User

Untitled

a guest
Jun 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. #define length 30
  6.  
  7. int main(){
  8. //Initialize variables
  9. int temp=0;
  10. int x=0;
  11. int y=0;
  12. char tempChar[length];
  13. char myString[length];
  14. char *reminderPtr;
  15. int day[length];
  16. char myReminders[length][length];
  17.  
  18. while(strcmp(myString,"0")!=0){
  19. //Ask user for the reminder
  20. printf("Enter day and reminder: ");
  21. gets(myString);
  22.  
  23. //Cut off the ending reminder
  24. reminderPtr= strtok(myString," ");
  25. x=atoi(reminderPtr);
  26. printf("%d\n",x);
  27.  
  28. day[y]=x;
  29. strcpy(myReminders[y],myString);
  30. y++;
  31. }
  32.  
  33. for(int a=0; a<length; a++)
  34. {
  35.  
  36. for(int b=0; b<length-1; b++)
  37. {
  38.  
  39. if(day[b]>day[b+1])
  40.  
  41. {
  42.  
  43. int temp = day[b+1];
  44.  
  45. day[b+1] = day[b];
  46.  
  47. day[b] = temp;
  48.  
  49. }
  50.  
  51. }
  52.  
  53. }
  54.  
  55. for(int v=0;v<length;v++){
  56. if(day[v]>0)
  57. printf("%d\n",day[v]);
  58. }
  59.  
  60. return 0;
  61. }
Add Comment
Please, Sign In to add comment