카타 7급 A Rule of Divisibility by 7

1 C[ | ]

int* seven(long long m) {
  int step = 0;
  while( m > 99 ) {
    m = m/10 - 2*(m%10);
    step++;
  }
  static int res[2];
  res[0] = m;
  res[1] = step;
  return res;
}
int* seven(long long m) {
  int step = 0;
  while (m > 99) {
    m = m / 10 - 2 * (m % 10);
    ++step;
  }
  int* res = (int*)malloc (2 * sizeof (int));
  res[0] = m;
  res[1] = step;
  return res;
}
int* seven(long long m) {
  static int res[2] = {};
  int cnt = 0;
  while (m > 99) {
    long long a0 = m % 10;
    m = (m - a0) / 10 - 2 * a0;
    cnt++;
  }
  res[0] = (int) m;
  res[1] = cnt;
  return res;
}

2 Kotlin[ | ]

3 R[ | ]

seven <- function(m) {
  step = 0
  while( m > 99 ) {
    step = step + 1
    m = m %/% 10 - ( 2 * m %% 10 )
  }
  c(m, step)
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}