Basics

 

½Ñ¦h statements(³¯­z,­z¥y)¥H¤À¸¹(;)Â_¥y. ¥i¥ô·NªÅ®æ©Î´«¦æ.

µù¸Ñ(comment)¥H /* µù¸Ñ¤º®e */ ©Î //µù¸Ñ¤º®e ¤è¦¡§e²{

n            n            µ{¦¡­n¦³²M·¡ªº±_ª¬µ²ºc

n            n            ¾i¦¨¼gµù¸Ñªº²ßºD

 

¤@­Ó project ªº¥Dµ{¦¡¥u¯à¦³¤@­Ó:

 

#include <¼Ð·ÇªíÀYÀÉ>

#include "¦Û­qÀÉ"

// »Ý­n¥Î¨ìªºªíÀYÀɤΦۭqÀɵ¥«e¸m³B²z(preprocessor)

int main()

{

³¯­z

return 0;

}

 

C/C++¤¤ªº«O¯d¦r(keywords)

auto

delete

goto

public

template

break

do

if

register

this

case

double

inline

return

typedef

catch

else

int

short

union

char

enum

long

signed

unsigned

class

extern

new

sizeof

virtual

const

float

operator

static

void

continue

for

private

struct

volatile

default

friend

protected

switch

while

 

¨ä¤¤ÂŦ⬰C++¤~¦³ªº. ¤£¥i¨Ï¥Î«O¯d¦r©R¦W ÃѧO¦WºÙ(identifier)¤ÎÅܶq(variable)

 

±`¥Îªº¼Ð·ÇªíÀYÀÉ

<stdlib> <iostream> <fstream> <istream> <ostream> <iomanip>

<math> <time> <algorithm> <vector> <string> ......

 

±`¥Îªº¤º«Ø¼Æ¾Ú«¬ºA(data type)

¹ê¼Æ: ¾ã¼Æ int, short, long, unsigned,

¯BÂI¼Æ float, double, long double, unsigned float, unsigned double, unsigned long double

½Æ¼Æ: complex<¹ê¼Æ><¹ê¼Æ> (³o¥s ½Æ¼Æªºtemplate)

ÅÞ¿è: bool (­È¬° true ©Î false, «O¯d¦r)

¦r¤¸: char (¦p ¡¦A¡¦,¡¦a¡¦,..., °Ñ¨£ ASCII¦r¤¸)

¦r¦ê: string (¦p ¡¨abcdefg¡¨)


ºâ¤l(operator)

uniaryºâ¤l:

++, --,

-(­t¸¹), !(Å޿誺§_©w), &(address-of), *(referencing)

binaryºâ¤l:

¹ê¼Æ¹Bºâ:

+(¥[),-(´î),*(­¼),/(°£), %(mod),

+= , -=, *=, /=, %= ,

==(µ¥©ó), !=(¤£µ¥©ó), < , <= , > , >= ,

¤G¶i¦ì¹Bºâ: >> , << , & , |,

ÅÞ¿è¹Bºâ: && , ||

 

¦³¥Í¦sªÅ¶¡/½d³ò(scope)ªº

°j°é(loop)

for(°_©l³]©w;±ø¥ó;§¹¦¨«á¤§°Ê§@) {³¯­z}

while(±ø¥ó) {³¯­z}

do {³¯­z} while(±ø¥ó);

¥Î continue ²¤¹L©Î break µ²§ô°j°é.

 

ÅÞ¿è±ø¥ó³]©w

¤@­Ó§PÂ_ÂI¦Ü¦h¨â­Ó¤e§Ã:

if(±ø¥ó) {³¯­z}

else{³¯­z}

©Î

if(±ø¥ó1) {³¯­z}

else if(±ø¥ó2) {³¯­z}

 

¤@­Ó§PÂ_ÂI¦³¦n´X­Ó§Ã:

switch(±¡ªp)

{

case ±¡ªp¤@: ³¯­z

case ±¡ªp¤G: ³¯­z

........

default: ³¯­z

}

±¡ªp¤@,¤G,... ¬°±¡ªpªº¹ê¨Ò, ¤£¥i¬°Åܶq. ¥i¥Î break ¸õ¹L¦U«áÄò cases. ¦p¤£ break, «h¨Ì§Ç°õ¦æ«áÄò cases.

default ¥Î¥H³B²z¥¼¦C¥X¤§case.

 

{}¤º¤´¥i¦³ for, while, do while, if³¯­z, ¬O¬°±_ª¬µ²ºc(nested structure).

Åܶq¦b ¬Y±ø¥ó¦¡/°j°é{}¸Ì«Å§i²£¥Í,

 

¨Ò¦p,

while( a > 1 )

{

  ³¯­z

  int b = 2;

  ³¯­z

}

 

«h, Â÷¶}while°j°é«á´N¨S¦³b³o­ÓªF¦è¤F. ³o¤@¹ï{}´N¬O©Ò¿×bªº¥Í¦sªÅ¶¡/½d³ò(scope). while ´«¦¨for, ifµ¥¤]¬O³o¼Ë.