タグ

Pythonとcに関するlamichのブックマーク (2)

  • 各言語間の参照と値渡し - @author pyridoxin

    参照渡しなるものではなく参照の値渡しが妥当だがそういう語彙の定義は件とは関係ないのでしません。 今回は「ある関数で仮引数を操作したら参照先が変更されて他の関数の実引数に影響を与えた」こととします。問題は以下 問題 二変数a,bを用意してそれぞれ1,2を代入し2 1と出力しなさい。ただし出力する前に自分で定義した関数を呼び出しa,bの値が2,1を指している状態にすること。もちろん関数の戻り値をa,bに代入してはダメです。swapをアンパック代入なしで実装しろという問いに近いかもしれません。 (穴の多い定義です。完全な定義を求む) 解答例 C #include <stdio.h> void swap(int *a,int *b); int main (void) { int a=1; int b=2; swap(&a,&b); printf("%d %d",a,b); return 0; }

    各言語間の参照と値渡し - @author pyridoxin
  • Micropolis - OLPC

    Micropolis is one of the oldest and grandest of city simulation games. A Linux port by Don Hopkins was released by Electronic Arts under the GPL for distribution on the XO (See Don Hopkins' blog for more background). Installing activity bundles can be simple or complex. If you are running Build 623, Ship.1, Ship.2, or something similar, and you have never installed Micropolis before, it should be

  • 1