Advertisement
erfanul007

LA 2189

Dec 1st, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<stdio.h>
  2. unsigned int num[100009];
  3.  
  4. int main()
  5. {
  6. unsigned int n,i,j,k,x,y,z,cn,cnt=0;
  7. while(1){
  8. cnt++;
  9. scanf("%u",&n);
  10. if(n==0)
  11. break;
  12. for(i=0;i<n;i++)
  13. scanf("%u",&num[i]);
  14.  
  15. num[n]=0;
  16. printf("Case %u:\n",cnt);
  17.  
  18. for(i=0;i<n;i++){
  19. if(num[i]+1 != num[i+1])
  20. printf("0%u\n",num[i]);
  21. else
  22. {
  23. printf("0%u-",num[i]);
  24. j=i+1;
  25. while(1){
  26. if(num[j]+1 != num[j+1])
  27. break;
  28. j++;
  29. }
  30. x=num[i];
  31. y=num[j];
  32. cn=10;
  33. while(x-(x%cn) != y-(y%cn))
  34. cn=cn*10;
  35.  
  36. z=num[j]%cn;
  37. printf("%u\n",z);
  38. i = j;
  39. }
  40. }
  41.  
  42. printf("\n");
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement