Blogs
Tech Blog |
Daily Blog
wch18735 / cpp-basic-practice-history Goto Github PK
View Code? Open in Web Editor NEWBasic C programming
Basic C programming
Blogs
Tech Blog |
Daily Blog
#include<stdio.h>
#include<string.h>
const int LM = 210;
int wcnt;
char buf[LM], * words[LM];
void split() {
char* token = strtok(buf, " ");
while (token) {
words[wcnt++] = token;
token = strtok(NULL, " ");
}
}
void insertionSort() {
int i, j;
for (i = 1; i < wcnt; ++i) {
char* tp = words[i];
for (j = i - 1; j >= 0; --j) {
if (strcmp(words[j], tp) > 0) {
words[j + 1] = words[j];
}
else break;
}
words[j + 1] = tp;
}
}
void output() {
int i, cnt = 1;
for (i = 1; i < wcnt; ++i) {
if (strcmp(words[i - 1], words[i]) == 0) cnt++;
else {
printf("%s : %d\n", words[i - 1], cnt);
cnt = 1;
}
}
printf("%s : %d\n", words[i - 1], cnt);
}
int main() {
//freopen("input.txt", "r", stdin);
while (scanf(" %[^\r\n]s", buf)) {
if (strcmp(buf, "END") == 0) break;
wcnt = 0;
split();
insertionSort();
output();
}
}
/*
* 배운 것
* 1. scanf()에 사용되는 정규표현식
* 2. insertionSort()
* 3. 창(W) 에서 새 창을 띄우면 한 쪽에 편집한 내용 옆에 동시 반영
* 4. strtok(NULL, delimeter) 는 이전에 찾았던 위치에서부터 다시 찾음
* 5. strcmp(str1, str2) 사용법
*/
알파벳 순서로 정렬 방법
=> 단순 string 비교 연산자 사용하면 자동으로 정렬된다
bool custom(string a, string b) {
return a < b;
}
책복사하기 문제
최적값 찾기
check()
: 최대 허용 가능 페이지가 mid일 때, 나눠지는 그룹 수 gCnt 가 주어지는 K 이하임을 만족하는가 에 대하여 가능/불가능 판단하는 함수
check()
를 Binary Search 판단 조건으로 활용해 최대 허용 가능 페이지가 mid일 때
,나눠진 그룹 수가 K개인
가 가장 작은 값
을 찾음
출력
배열을 역순으로 탐색하는 DFS 함수 작성
후위 순회 진행 (탐색의 끝부터 출력을 진행하며 돌아옴)
void dfs(){
// base condition
// search
// print()
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.