[소스 코드]
https://github.com/henlix/data-structure.git
https://github.com/henlix/calculator
[설명]
대학생 연합 IT 벤처 창업 동아리 S.O.P.T (Shout Our Passion Together - http://sopt.org) 에서 내부적으로 진행하는 전공 과목 기초 스터디 자료입니다.
이번주에 다룰 내용은 기본적으로 자료구조에서 다루는 스택, 큐 그리고 스택을 응용한 수식 연산에 대한 구현입니다.
스터디 자료는 다음과 같은 순서대로 올라갈 예정입니다.
1. 데이터 구조 및 알고리즘
2. 운영체제
3. 네트워크
[소스 코드]
https://github.com/henlix/data-structure.git
https://github.com/henlix/calculator
[설명]
대학생 연합 IT 벤처 창업 동아리 S.O.P.T (Shout Our Passion Together - http://sopt.org) 에서 내부적으로 진행하는 전공 과목 기초 스터디 자료입니다.
이번주에 다룰 내용은 기본적으로 자료구조에서 다루는 스택, 큐 그리고 스택을 응용한 수식 연산에 대한 구현입니다.
스터디 자료는 다음과 같은 순서대로 올라갈 예정입니다.
1. 데이터 구조 및 알고리즘
2. 운영체제
3. 네트워크
This document discusses structures in C programming. It explains that structures can contain elements of different data types, accessed by name, unlike arrays where all elements must be of the same type and accessed by index. It provides examples of declaring a structure type with members, defining structure variables, accessing members using the dot operator, passing structures to functions, and initializing an array of structures.
The document discusses call-by-value in function invocation in C. When a function is called, only the values of the arguments are passed to the function, not the variables themselves. So any changes made to the parameters inside the function are not reflected in the calling function. This causes an issue when trying to swap variables by passing them to a Swap function.
2. Use of printf() and scanf()
printf()는 Print Format의 약어로, 화면에 내용을 출력할 때 사
용하는 명령(함수)이다.
printf(“format string..”, argument list);
[Ex]
#include <stdio.h>
int main() {
int n ;
n = 25 * 10;
printf(“%d”, n);
}
[Ex]
printf(“%c%c%c”, ’a’, ’b’, ’c’ );
printf(“%s”, “def” );
/* 250 이 출력된다. */
/* abc 가 출력된다. */
/* def 가 출력된다. */
2
3. Use of printf() and scanf()
Conversion characters (format string)
%c
character (문자)
printf(“%c”, ’a’);
%d
decimal integer (10진수로출력) printf(“%d”, 100);
%x
Hexadecimal integer
(16진수로출력)
printf(“%x”, 100);
%o
Octal integer (8진수로출력)
printf(“%o”, 100);
%u
Unsigned decimal (양수로출력)
printf(“%u”, 100);
%e
floating point number in
scientific notation
printf(“%e”, 1.234);
%f
floating point number
printf(“%f”, 1.234);
%g
e-format또는 f-format
printf(“%g”, 1.234);
%s
string (문자열)
printf(“%s”, ”C-book”);
3
4. Use of printf() and scanf()
The Use of printf() : integer %d
printf(“ %md”, a );
printf(“ %-md”, a);
/*m 정수.오른쪽정렬 */
/*m 정수. 왼쪽정렬 */
[Ex]
a = 12;
printf(“%5d%-5d%dn” ,a, a, a+11);
12^^^^^^1223
– %5d로 출력 : 12^^^
( 5자리에 왼쪽정렬로 출력, 뒤쪽 공간이 남으면 공백으로 채움)
– %-5d로 출력 : ^^^12
( 5자리에 오른쪽정렬로 출력, 앞에 공간이 남으면 공백으로 채움)
– %d로 출력 : 23
(a +11의 값 ‘23’을 그대로 출력)
4
5. Use of printf() and scanf()
The Use of printf() : float %f
printf(“ %m.pf”, a );
printf(“ %-m.pf”, a);
/*m, p 정수.오른쪽정렬 */
/*m, p 정수. 왼쪽정렬 */
[Ex]
83.1260^^83.126083.126000^^^83.13
a = 83.126;
printf(“%8.4f%-8.4f%f%-7.2fn”, a, a, a, a );
– %8.4f : 83.1260^
(소수점을 포함 총 8자리에 숫자를 출력하되 소수점 이하 4자리까
지 표시. )
– %-8.4f : ^83.1260
(%8.4f와 동일 , 그러나 음수로 인해 오른쪽으로 정렬)
– %f
: 83.126000
(칸수 제한 없이 소수점 이하 6자로 출력)
– %-7.2f : ^^^83.13
(7자리 확보에 소수점 이하 2자리-반올림, 오른쪽 정렬)
5
6. Use of printf() and scanf()
Use of scanf()
– scanf() - key board로부터 data를 입력 받기 위해 사용하는 함수이
다.
scanf(“format string..”, argument list);
%c
character (문자)
scanf(“%c”, &a);
%d
decimal integer (10진수)
scanf(“%d”, &a);
%f
floating point number (float)
scanf(“%f”, &a);
%lf
floating point number (double)
scanf(“%lf”, &a);
%Lf
floating point number (long double)
scanf(“%Lf”, &a);
%s
string (문자열)
scanf(“%s”, &a);
6
7. Use of printf() and scanf()
[Ex]
#include <stdio.h>
int main() {
int n ;
printf(“Enter number : “);
scanf(“%d”, &n);
printf(“You entered : %d”, n);
return 0;
}
Enter number : 10
You entered : 10
7