Skip to content

Instantly share code, notes, and snippets.

@itmir913
itmir913 / C++.cc
Created February 19, 2022 14:15
[OJ Code Template] 알고리즘 문제 풀 때 언어 별 코드 템플릿
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a+b << endl;
return 0;
}
@itmir913
itmir913 / main.c
Last active May 29, 2021 13:53
[1차원 배열 동적할당] C언어 동적 배열 할당 #배열 #동적할당
#include <stdlib.h>
int *createArray(int num) {
int *arr = (int *) malloc(sizeof(int) * num);
for (int i = 0; i < num; i++) {
*(arr + i) = i;
}
return arr;
@itmir913
itmir913 / main.c
Last active May 10, 2021 23:26
[2차원 배열 동적할당] C언어 malloc 함수로 2차원 배열 동적할당하기 #배열 #동적할당
#include <stdio.h>
#include <stdlib.h>
int **createMatrix(int height, int width) { // https://codeng.tistory.com/8
int **arr;
arr = (int **) malloc(sizeof(int *) * height);
arr[0] = (int *) malloc(sizeof(int) * width * height);
for (int i = 1; i < height; i++) {