apl-mhd

UVAfinal

Feb 8th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstdio>
  5. using namespace std;
  6.  
  7. int main(int argc, char **argv)
  8. {
  9.  
  10.    int phone[10000];
  11.     int i, number,start,count=0,tCase=1,n;
  12.  
  13.     while(scanf("%d",&n)==1,n){
  14.  
  15.         for(i=0;i<n;i++)
  16.             scanf("%d",&phone[i]);
  17.  
  18.         printf("Case: %d\n",tCase++);
  19.  
  20.         for(i = 0; i<n; i++){
  21.             if(phone[i+1] - phone[i] == 1){
  22.  
  23.  
  24.                 count++;
  25.             }
  26.  
  27.  
  28.             else if(count > 0) {
  29.  
  30.                 start = i - count;
  31.                 printf("0%d-%d\n",phone[start],phone[start] + count);
  32.  
  33.  
  34.                 count = 0;
  35.  
  36.                 }
  37.  
  38.             else{
  39.  
  40.                     printf("0%d\n",phone[i]);
  41.  
  42.                 }
  43.  
  44.  
  45.             }
  46.  
  47.  
  48.  
  49. }
  50.     return 0;
  51. }
Add Comment
Please, Sign In to add comment