http://www.hackerschool.org/HS_Boards/zboard.php?id=Free_Lectures&no=434 []
õ geniusevil c ̾ڽϴ.
2°? ϽDZ ڳ.
1° źе 1° ñ ٶϴ.
1° ּ : http://www.hackerschool.org/HS_Boards/zboard.php?id=Free_Lectures&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=433
غ
- 1° -
#include <stdio.h>
- #include ҷ´. Լ ǵǾִ ̴.
stdio.h Է,¿ õ Լ ǵǾִ.
main() { }
- α ü̴.
printf()
- ڿ̳ ϴ Լ̴. %d ־ָ Ҽ ִ.
//
- ̴ּ. ּ α ҽ α ̴.
int name;
- Ѵ. ڶ Ҽִ. ڸ ְ ڸ ִ.
ϴ.
+,-,*,/,%,++,-- ڴ ⺻ Ƽžմϴ.
- ೡ. 1° 1°¸ ذ Ȱ Ƿ
1° ¸ ! -
2° ¸ մϴ
----------------------------------------------------------------------
3
1:#include <stdio.h>
2:
3:main()
4:{
5: int intvari=32767; //int ÿ 32767
6: char charvari='A'; //char ÿ A
7: long longvari=214748367; //long ÿ 214748367
8: float floatvari=3.14; //float ÿ 3.14
9: double doublevari=3000.143; //double ÿ 3000.143
10:
11: printf("int %d \n", intvari);
12: printf("char %c \n", charvari);
13: printf("long %ld \n", longvari);
14: printf("float %f \n", floatvari);
15: printf("double %f \n", doublevari);
16:}
α: ˸ ϰ ˸ ȯڸ Ͽ մϴ
! - ȣ ̴ Ϸ ȣ Է
5 - 9 ø ̶ ƽǰ̴ϴ.
ϴ ÿ ? ̷ ϸ 2 1ٷ ϼֽϴ.
ó char,long,float,double Ư¡ ֽϴ.
Ʒ - ܿ Ұ!- մϴ.
11 - 15 մϴ. ƽ?
ȯ(%d %c) ٲ? Ư¡ ȯڰ پմϴ.
ȯ Ʒ - ܿ Ұ!- մϴ.
ذ ð ^^?
.
.
.
.
.
----- ܿ Ұ! ------
-
Ű
int(2Ʈ) -32768 ~ 32767
short short(2Ʈ) -32768 ~ 32767
long(4Ʈ) -214748368 ~ 214748367
char(1Ʈ) -128 ~ 127
ȣ unsigned int 0 ~ 65535
ȣ¹ unsigned char 0 ~ 255
ȣ± unsigned long 0 ~ 4294967295
εҼ float(4Ʈ) 1.2E-38 ~ 3.4E38^1
εҼ double(8Ʈ) 2.2E-308 ~ 1.8E308^2
ɼ ִ Ѱ̸ ܿ ʿ ϴ.
ٸ ˰ ž߰.
- ȯ
ϴ ȯڴ ´°͵ ֽϴ.
int %d ´°.
%d (int,short)
%ld (long)
%f εҼ (float)
%lf εҼ (double)
%c Ѱ (char)
%s ڿ (char 迭)
%u ȣ (unsigned int)
%lu ȣ (unsigned long)
4
1:#include <stdio.h>
2:
3:main()
4:{
5: int sep;
6: printf("1 2 ڸ Էϼ --> ");
7: scanf("%d", &sep); //α ڷκ Է¹ϴ
8:
9: printf("\n");
10:
11: if(sep == 1) //sep 1
12: {
13: printf("1 Էϼ̽ϴ\n");
14: }
15: else if(sep == 2) //sep 2
16: {
17: printf("2 Էϼ̽ϴ\n");
18: }
19: else // Ұ
20: {
21: printf("1̳ 2 ƴմϴ\n");
22: }
23:}
α : 1̳ 2 Է¹ް Էߴ ˷ݴϴ
7 scanf()ԼԴϴ.
scanf("%d", &sep);
scanf()Լ α ڿԼ Է¹ϴ.
Է¹ "ȯ" & մϴ.
ȯ, մϴ.
long Է¹ް ϸ
long abc;
scanf("%ld", &abc);
ϸ. ̸ տ & ٿִ ּҸ Ű Դϴ.
ּ? ʿ䰡ϴ ^^ ߿ Ͱ 鼭 ˰ԵDZ .
̸տ & ٿش. ƽø ˴ϴ.
int a,b,c;
scanf("%d %d %d", &a, &b, &c); ϸ Ѳ ֽϴ.
)
int intvri;
char charvri;
scanf("%c %d", &intvri, &charvri);
Էâ : 74 K
° մϴ.
! - scanfԼ ̸տ & ʴ´.
11 - 22 if()Լ Դϴ
if ǹ Ǹ {} ȿ ִ° մϴ.
ǹ̶? (sep == 1) ó Ǵ¹. 1° ?
if ȣ иմϴ ( {} )
15 else if ִ if else if ǹ ˻մϴ.
⼭ if ؼ 쿣 else if ˻ʰ ׳ Ѿϴ.
ƿ ϴ°.
else if Ǽ ֽϴ.
if ()
{
}
else if ()
{
}
else if ()
{
} .
Ʒ 19 else if ǹ else if ǹ Ѵ Ҷ ˴ϴ.
ǽð ^^?
.
.
.
.
.
------ ˾ƵѰ! ------
ȣ° ֽϴ.
#define ONE 1
̷ ϰ Ǹ ( main()Լ մϴ)
ONE ڴ 1 Ȱ ˴ϴ. ̸ 빮ڷ մϴ. ְŵ.
if( > 1) if( > ONE) ִ°
̰ ʿϳ? Ǽ ְ ߿ c ٺ ϴٴ° ˰Եǽǰ̴ϴ^^
#define ϴ ְ ٸ ֽϴ.
const int one = 1;
̷ ϸ one 1 ǰ Ҽ ˴ϴ.
const Ϸ Ѵٸ Ҽ ̴ϴ.
one = 5; // Ҽ! const Ұ
ȣ ߿ ϰԵǸ ˼̴ϴ.
- ǿ α ! -
̹ α ڽϴ ..
Ѱ ƴϱ.. - -; Է¹ް ϱ ϱ ⸦ ϴ ʺ Դϴ.
αٰŸʳ ?! ó Ȱ ִ α ٴ°..
ó c α αٵαٰŷȴϴ ^^ I can do it!
α1 - μڰ
#include <stdio.h>
main()
{
#define PLUS 1 //ȣ
#define MINUS 2
#define AGAIN 3
#define DIVIDE 4
int sep, first, second, dival; //,ó,°,
long val; //val °̸ ū ޱ long
printf("μ Դϴ. \n");
printf(":1 :2 :3 :4 -> ");
scanf("%d", &sep);
printf("ù Էϼ");
scanf("%d", &first);
printf("ι° Էϼ");
scanf("%d", &second);
printf("\n");
if(sep == PLUS) //ȣ Ͽ (sep==1) ȿ
{
val = first + second;
printf(" %ldԴϴ", val);
}
else if(sep == MINUS)
{
val = first - second;
printf(" %ldԴϴ", val);
}
else if(sep == AGAIN)
{
val = first * second;
printf(" %ldԴϴ" ,val);
}
else if(sep == DIVIDE)
{
val = first / second;
dival = first % second;
printf(" %ld, %dԴϴ", val, dival);
// long Ҽ ϹǷ иѴ
}
else
{
printf("1 - 4 ϳ žմϴ");
}
}
ִ° ۵ ؼϽ Ƽžմϴ ̿ ^^
ϳ, α switch()Լ ̿ϸ ȿ α մϴ.
if 쿣 else if ˻ϰ Ѿ ݸ鿡 ġ ִ° ¤ ϰŵ.
ذ ȵǵ ϴ ^^ switch() Űŵ.
Կ.
! - α иϿ Ͽ.
и Ҽ Ͽ α ƶ.
غô° ϴ ^^
˻ .. :) Ƿ غ.
ڴ ϼ. ۷ ϼŵ ǰ Ȩǿ ż ϼŵ ˴ϴ^^
Copyright2006 geniusevil( http://www.cyworld.com/01028852864 ) .All rights reserved
Ȥó ۰÷ ^^;;; ǥø ø ۰ŵ ˴ϴ |
Hit : 10018 Date : 2006/01/09 01:20
|