http://www.hackerschool.org/HS_Boards/zboard.php?id=Free_Lectures&no=456 []
ۿ ٽ øϴ.
ð гڼ̴ е鲲 ˼ϰ.. '--;' Կ 帳ϴ.
ణ ߽ϴ. ȴٸ ٽ ֽø ϰڽϴ
---------------------------------------------------
õ geniusevil C ̾ϴ ^^
3°Դϴ. 2° Ⱥ ź 1°,2° ñ..
غ .
- 2° -
Ű
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
ȯ
%d (int,short)
%ld (long)
%f εҼ (float)
%lf εҼ (double)
%c Ѱ (char)
%s ڿ (char 迭)
%u ȣ (unsigned int)
%lu ȣ (unsigned long)
scanf() : ڷκ Է Լ.
if() : ǹ ̸ {} Ѵ
else if() : if ̰ else if ǹ ̸ {} Ѵ
else () : ̸ else Ѵ
ȣ : #define , const int = ;
Ѵ.
--------------------------------------------.
2° ,,, ұ ߴ ϳ? :)
if ̿ؼ sep̶ ڿ 1 Ǿ , 2 Ǿ ̷ .
c ̷ ִ Լ ִϴ. switch Լ.
if switch 鿡 ȿԴϴ. ̶ α ҽ ϱ Դϴ
鿡 switch ȿ̶ Ҽ.
ߴ switch ؼ ڽϴ.
! ¾? Ҽ ϱ װ 䵵 ⼭ ɴϴ ^^
5
0: #include <stdio.h>
1:
2: main()
3: {
4: int sep;
5: float first, second, dival; //ó,°, Ҽ
6: float val; // Ҽ
7:
8: printf("--------------------------------------\n");
9: printf("μ Դϴ. \n");
10: printf(":1 :2 :3 :4 ->");
11: scanf("%d", &sep);
12: printf("--------------------------------------\n");
13:
14: printf("ù° Էϼ ->");
15: scanf("%f", &first);
16: printf("ι° Էϼ ->");
17: scanf("%f", &second);
18:
19: printf("\n");
20:
21: switch (sep)
22: {
23: case 1 :
24: val = first + second;
25: break; // switchԼ ̽ȿ break ־Ѵ.
26: case 2 :
27: val = first - second;
28: break;
29: case 3 :
30: val = first * second;
31: break;
32: case 4 :
33: val = first / second;
34: break;
35: }
36: printf("--------------------------------------\n");
37: printf(" %.1fԴϴ.", val); // float Ҽ 1ڸ
38: printf("\n--------------------------------------\n");
39: }
α : Ҽ µǰ ġ
21 - 35 switchԼԴϴ ^^
switch (ù ȣ ִ )
{ // ߰ȣ switch Լ Ѵ
case ȣ :
break;
case ȣ :
break;
}
Դϴ. ȣ κп charԼ ڰ ֽϴ.
ù ȣ ִ 2 ִٸ. case 2 : ãư case 2 break; ˴ϴ.
break; switch ģ Ҽֽϴ. پٴ.
switch case ȣ: 븸 ϴ° ƴ϶ case ȣ ġ ̵Ѵٰ ֽϴ. ̵ؼ Ʒ 鼭 ȴٸ ġ ƴ. 5 ε case 2 õƴٸ case 2 case 3 case 4 ǰ. ġ ƴ ¥ ̵˴ϴ.
װ ġ break; ϴ. break; '߰ȣ ' Դϴ.
case 2 õǼ case 2 ϰ break; switch ߰ȣ case 2 ǰ.
37 val ϴ ȯڰ ̻ ^^? %.1f ó°ǵ.. Ͻôº ð.
%.1f 'Ҽ 1ڸ ϶' Դϴ. ȯ Ư Ʒ ܿҰ! մϴ.
Ͻð.. ? ^^
.
.
.
.
.
- ܿ ! -
ȯ Ưɼ
%4d - ĭ 4ĭ ´ : ' 11'
%-4d - ĭ 4ĭ Ѵ : '11 '
%09 - ü ĭ 9ĭ 0 ä : '000000011'
%+d - ȣ : '+11 , -11'
%.2f - Ҽ 2ڸ : '5.43'
%7.2f - ĭ 7ĭ Ҽ 2ڸ : ' 5.43'
.. ù .. ݺ̶° ֽϴ.
϶ ϰ ٽ ˻ؼ ̸ ٽ ϴ Լε.
while, for, do while ֽϴ.
6
0: #include <stdio.h>
1:
2: main()
3: {
4: int val, i;
5:
6: printf("100 ڸ ԷϽÿ");
7: scanf("%d", &val);
8:
9: if (val > 100)
10: val = 100;
11:
12: printf("\n");
13:
14: i = 1;
15:
16: while (i <= val)
17: {
18: printf("%d ", i);
19: i++;
20: }
21: }
α : ִ밪 Է¹ް ڿ Ѵ.
14 - 20 ø while ƽǰ̴ϴ.
while(ǹ)
{
} // ٽ ǹ ˻
̷ µ ǹ ̸ ϰ ٽ ǹ ˻մϴ.
ǹ ɶ .
α 14 i 1 . while ͼ
..
14: i = 1;
15:
16: while (i <= val)
17: {
18: printf("%d ", i);
19: i++;
20: }
ٷ ذϴ ֽϴ.
ٷ for .
for (i=0; i<=val; i++)
{
printf("%d ", i);
}
̷ ŵ Ȱ ȿ մϴ.
for
for(ʱ; ǹ; )
{
}
Ǵµ ʱ i = 0; ó ϴ Դϴ.
ǹ i < 10; ó ó ̸ ߰ȣ {} մϴ.
߰ȣ ϰ ϴµ i++ , --a 1 Ű ϴ.
Ŀ ٽ ǹ ˻ؼ ̸ ߰ȣ {} մϴ. ̰ ݺǴٰ ǹ 츦 dzʶٰ Ǵ .
i = 1;
while (i <= val)
{
printf("%d ", i);
i++;
}
for (i=0; i<=val; i++)
{
printf("%d ", i);
}
ϴ.
ð ^^?
7
0: #include <stdio.h>
1: #include <conio.h>
2:
3: main()
4: {
5: int sel;
6: char a;
7: do
8: {
9: printf(" Ұ ҽ\n");
10: printf("y,Y , n,N \n");
11: printf(" Ű \n");
12: do
13: {
14: sel = 2;
15: printf("\n Ͻ÷ Y , ÷ N \n ->");
16: a = getch();
17: putch(a);
18: printf("\n");
19: } while (a != 'Y' && a != 'y' && a != 'N' && a != 'n');
20: if (a == 'Y' || a == 'y')
21: sel = 1;
22: else if (a == 'N' || a == 'n')
23: sel = 0;
24: } while (sel == 1);
25: }
α : Ұ ൿ ϴ α
! : getch putch ̹ ̸ ʵ Ѵ.
̹ ݺ do whileԴϴ.
do while do ߰ȣ {} ѹ ϰ Ʒ while ˻ ̸ , ̸ Ѿϴ.
while while ó ˻ϰ , ϴ°Ϳ do while ѹ ȴٴ Դϴ.
ҽ do while ͵ϽǼ ٵ.
7 - 24 do whileԴϴ. do whileȿ do while ? ̷͵ ϴϴ.
ϴ Ǽ ϳϳ ؼغ ϰڽϴ.
ϴ 7 do ȣ printf մϴ.
12 do ȣ ϴ. sel̶ 2 ְ printfԼ մϴ.
getch()Լ a µ.
getch()Լ ڳ ڸ Ѱ ԼԴϴ. a = getch(); ϸ ڳ ϳ Ƽ a ִ°.
⼭ y n մϴ.
Ʒ putch(a); a մϴ. getch() ڰ Է Ϳ ʱ ڰ 찡 ְŵ. װ ϱ putch();Լ ݴϴ.
do while ǹ κ ߿մϴ!
a != 'Y' && a != 'y' && a != 'N' && a != 'n'
̰ ؼϸ a 'Y' ʰ a 'y' ʰ a 'N' ʰ a 'n' Դϴ. ðڴٱ? ;;..
ڸ ڰ ԷѰ Y,y,N,n߿ ϳ ƴҽÿ ٽ do Ͽ ٽ °Դϴ.
Y,y,N,n ϳ Էߴٸ do while 20 .
ִ ڶ Ͽ Ʒ ܿ Ұ! մϴ.
20 a == 'Y' || a == 'y' ̷ ؼմϴ.
a 'Y' Ǵ a 'y' .
Դϴ. ̰͵ Լϸ ڰ ԷѰ y̰ų Y̸ Ǿ if ȣ մϴ.
̸ ̰ sel 1 ǰ .
ƴϸ ȣ ϰ ׳ Ʒ 22 else if .
⼭ a n̰ų Ǵ a N̸ sel 0 ǰ ˴ϴ.
Ʒ ͼ 24 while sel 1 Ǿ do ư ٽ ϰ ǰ sel 1 ƴϸ ׳ Ʒ α .
ذ ǽð ^^?
.
.
.
.
.
.
- ܿ Ұ! -
&& : [] ϶ ) (a && b)
|| : [Ǵ] ߿ ϳ ϶ ) (a || b)
! : [] ̸ ̸ ) ( !(a = 0) )
.. 3° .
7 α α ˴ϴ.
α Ұ Ұ ° ^^.. ͵ մϴ.
. İ ߿Ѱ ƴϰ.. ϴİ ߿մϴ ^^
ð ϰ ϰ Ѿô.
c ٽ Լ 쵵 ϰڽϴ ּ ' - ' ¸ ֽô е մϴ
ذ ȵǽô° ðų Ͻǰ ø ̳ Ȩǿ ϼ ^^
Copyright2006 geniusevil( http://www.cyworld.com/01028852864 ) .All rights reserved
Ȥó ۰÷ ^^;;; ǥø ø ۰ŵ ˴ϴ |
Hit : 11357 Date : 2006/01/19 04:18
|