ForNext
Only Do What Only You Can Do
2-1-1 構造体とメンバの透過性
VBScript
JScript
Perl
PHP
Python
Ruby
PowerShell
Scala
F#
C
C++
更新日 : 2010.10.14
#include <stdio.h> struct student { char name[20]; int eng; int math; int ave; }; void calc_ave(student* x) { x->ave = (x->eng + x->math) / 2; } int average(student* x) { return x->ave; } int main(int argc, char* argv[]) { student x; x.eng = 60; x.math = 70; calc_ave(&x); printf("eng = %d\n", x.eng); printf("math = %d\n", x.math); printf("ave = %d\n", average(&x)); return 0; }
R:\>lesson002\project1.exe eng = 60 math = 70 ave = 65
C++Builder
VC++
C#
Java
Objective-C
D
VB
VB.NET
Delphi
更新日 : 2010.09.24
program Project1; {$APPTYPE CONSOLE} uses SysUtils; type TStudent = record eng: Integer; math: Integer; ave: Integer; end; procedure calc_ave(var x:TStudent); begin x.ave := (x.eng + x.math) div 2; end; function average(x:TStudent):Integer; begin result := x.ave; end; procedure main(); var x: TStudent; begin x.eng := 60; x.math := 70; calc_ave(x); Writeln(Format('eng = %d', [x.eng])); Writeln(Format('math = %d', [x.math])); Writeln(Format('ave = %d', [average(x)])); end; begin main; end.
S:\>lesson002\project1.exe eng = 60 math = 70 ave = 65