19
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C言語の小ネタ集

Last updated at Posted at 2017-04-08

URL直書き

direct_url.c
void complex_algorithm()
{
  https://en.wikipedia.org/wiki/Complex_Algorithm
  /*
   * 複雑なアルゴリズムのコード
   */
}

--> 演算子(1)

goto_operator1.c
#include <stdio.h>

int main()
{
  int n = 5;
  do {
    printf("%d ", n);
  } while (n --> 1);
  printf("done!\n");
}
実行結果
5 4 3 2 1 done!

--> 演算子(2)

goto_operator2.c
#include <stdio.h>

int main()
{
  int n = 10;
  while (n --\
              \
               \
                \
                 > 1)
    printf("%d ", n);
}
実行結果
9 8 7 6 5 4 3 2 1 

??!??! 演算子

magic_operator.c
#include <stdio.h>

int magic_operator(int a, int b)
{
  return a ??!??! b;
}

int main()
{
  int r = magic_operator(42, 0);
  printf("result = %d\n", r);
}
実行結果
result = 1

-=- 演算子

balance_operator.c
#include <stdio.h>

int main()
{
  int i;
  for (i = 0; i < 10; i -=- 1) {
    printf("%d ", i);
  }
}
実行結果
0 1 2 3 4 5 6 7 8 9 

べき乗演算子

pow_operator.c
#include <stdio.h>

int main()
{
  printf("%d", 50 ** "2");
}
実行結果
2500
19
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?