MUstar

IoT C언어 0703 - EX_03 (줄압축)

Jul 3rd, 2017
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     int num[10], plus = 0 ,cnt=0, ec=0, res;
  6.     while(1)
  7.     {
  8.         res = getchar(); if(res==10) break;
  9.         else{num[cnt] = res - 48; cnt++;}
  10.     }
  11.     while(2)
  12.     {
  13.         int digi=1, i=1;
  14.         if(cnt>1) {cnt--; while(3){digi = digi * 10; if(i==cnt) break; else i++;} plus = digi * num[ec] + plus; ec++;}
  15.         else {plus = plus + num[ec]; break;}
  16.     }
  17.     printf("%d\n", plus+10); return 0;
  18. }
RAW Paste Data