S

@suho4849

메모리 크기를 입력받고 입력한 값 출력하기

C
18 hours ago
#include <stdio.h> #include <stdlib.h> int main(){ int n; scanf("%d", &n); if(n <= 0) return 1; // 한 줄로 쓸 수도 있음 int *arr = malloc(sizeof(int)* n); if(arr == NULL) return 1; for(int i = 0;i < n;i++){

11/11 메모리 할당/ 주소

C
18 hours ago
#include <stdio.h> #include <stdlib.h> int main() { int a = 10; int *p = &a; printf("%d\n", a); printf("%p\n", &a); // 주소(&)를 출력할 때는 %p! printf("%d\n", *p); *p = *p + 20;

MINECRAFT C EDITION

C
2 weeks ago
#include "main.h" #include "world.h" #include "player.h" void render_console_slice() { // 플레이어의 현재 높이(y) 단면에 있는 블록들을 간단히 콘솔에 출력 int py = (int)player.y; if (py < 0) py = 0; if (py >= WORLD_HEIGHT) py = WORLD_HEIGHT - 1;

2차원 배열

C
2 weeks ago
#include <stdio.h> int main() { int a[2][10]; // 2개의 배열을 한 배열을 생성하고 그 배열 안에 10개의 숫자가 들어갈수 있게 생성 int b[2][3] = { {10, 20, 30}, {100, 200, 300} }; // 2차원 배열안에 숫자를 넣을때

배열과 함수

C
2 weeks ago
#include <stdio.h> void Print_Array(int a[], int size); int main(void) { int nums1[5] = {7, 15, 10, 4, 11}; Print_Array(nums1, 5); return 0; } void Print_Array(int a[], int n){

랜덤한 수

C
3 weeks ago
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); // 난수 초기화 printf("1~5사이의 랜덤한 수 : %d\n", rand() % 5+1); // 랜덤 한 수 선택(1~적은수 보다 1적은수로 됨) }

배열

C
3 weeks ago
#include <stdio.h> #include <string.h> int main(){ int a[10]; a[0] = 1; a[1] = 2; a[2] = 3; printf("%d %d %d\n", a[0], a[1], a[2]); int b[10] = {0,0,0,0,0,0,0,0,0,0};

지역변수, 전역변수

C
4 weeks ago
#include <stdio.h> int a = 1234; int asdf(){ printf("%d\n", a); int b = 999; printf("%d\n",b); } int main() {

함수2

C
4 weeks ago
#include <stdio.h> int add(int a, int b); void add2(int a, int b); int minus(); void print(); int main() { printf("%d\n",add(1,2)); add2(5,995);

함수1

C
4 weeks ago
#include <stdio.h> int add(int a, int b){ int c = a + b; return c; } void add2(int a, int b){ printf("%d\n", a+b); }

switch문 숙제

C
4 weeks ago
#include <stdio.h> int main(){ printf("나온 점수를 입력하세요\n"); int a; scanf("%d", &a); printf("%d점은 ", a); a = a / 10; switch (a){ case 10:

조건문

C
4 weeks ago
#include <stdio.h> int main() { int a; scanf("%d", &a); if(a>=5){ printf("A는 5이거나 5보다 큽니다.\n"); }else if(a>=3){ printf("A는 3이거나 3보다 큽니다.\n"); }else{

반복문

C
1 month ago
#include <stdio.h> int main(){ int a; a = 1; while(a<-5348){ printf("%d\n",a); a++; a++; }

입력, 출력

C
1 month ago
#include <stdio.h> int main() { int a; a = 10; int b = 20; // int는 정수 printf("%d %d %d\n", a, b, 999); // \n은 줄 바꾸기 const int asdf = 1234; // const는 안 바뀌는 수 float c = 0.142857; // %c는 문자(한글자) printf("%.9f\n", c); //

21. 지역변수/ 전역변수

Python
1 month ago
# ===== 전역 변수와 지역 변수 ===== # 전역 변수(Global Variable) # 함수 밖에서 만든 변수 # 함수 안에서도 볼 수 있고, 함수 밖에서도 볼 수 있다. # 지역 변수(Local Variable) # 함수 안에서 만든 변수 # 함수 안에서만 사용할 수 있다.

19. 함수 - 내장함수/정의함수

Python
2 months ago
# ===== 함수 개념 ===== # 함수(function) # 어떤 입력을 받아서 특정 작업을 수행한 후 결과를 알려주는 도구 # 내장 함수: 파이썬에 기본으로 들어있는 함수 ''' print() : 값을 화면에 출력 input() : 값을 입력받음 len() : 길이를 알려줌

평균구하기

Python
2 months ago
print("평균구하기") a = 0 b = int(input("수의 갯수를 입력하세요")) print() for c in range(1,b): d = int(input("%d번째 수를 입력하세요"%(c))) a = a + d print() print("평균은 %3.4f입니다"%(a/c))

20. 함수 - 사용자 정의함수

Python
2 months ago
# ===== 사용자 정의 함수 ===== # 함수(function) # 어떤 작업을 여러 번 쉽게 하기 위해 만든 "코드 묶음" # 기본 형태 ''' def 함수이름(매개변수): 실행할 코드 return 반환값 # 필요할 때만 사용