-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
|
||
int main(void) { | ||
char A[5][16] = {}; | ||
for(int i = 0; i<5; i++){ | ||
scanf("%s", A[i]); | ||
} | ||
for(int i = 0; i<15; i++){ | ||
for(int j = 0; j<5; j++){ | ||
if (A[j][i] != '\0'){ | ||
printf("%c", A[j][i]); | ||
} | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int fib(int n){ | ||
if(n<=1) return n; | ||
return fib(n-1)+fib(n-2); | ||
} | ||
|
||
int main() { | ||
int N; | ||
cin >> N; | ||
cout << fib(N); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int comb(int N, int K){ | ||
int res = 1; | ||
for(int i=N; i>=K; i--){ | ||
res *= i; | ||
} | ||
for(int i=1; i<=K; i++){ | ||
res /= i; | ||
} | ||
|
||
|
||
} | ||
|
||
int main(){ | ||
int N, K; | ||
cin >> N >> K; | ||
cout << comb(N, K); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <cstdio> | ||
#include <cstring> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int n,cnt=0,ans=0,chk=0; | ||
scanf("%d",&n); | ||
|
||
for(int i=0;i<n;i++){ | ||
char s[101]={}; | ||
scanf("%s",s); | ||
|
||
int c[101]={s[0],}; | ||
int ls = strlen(s); | ||
for(int j=1;j<ls;j++){ | ||
if(s[j]!=s[j-1]) cnt++; | ||
c[cnt] = s[j]; | ||
} | ||
|
||
sort(c,c+(cnt+1)); | ||
|
||
for(int i=1;i<cnt+1;i++){ | ||
if(c[i]==c[i-1]) chk++; | ||
} | ||
|
||
if(chk==0) ans++; | ||
cnt = 0; | ||
chk = 0; | ||
} | ||
printf("%d",ans); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <stdio.h> | ||
|
||
int main(void) { | ||
int A[100][100] = {}; | ||
int B[10000] = {}; | ||
int N; | ||
scanf("%d", &N); | ||
for(int i = 0; i<N; i++){ | ||
for(int j = 0; j<N; j++){ | ||
scanf("%d", &A[i][j]); | ||
if(A[i][j] <= 0){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
else if(A[i][j] > N*N){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
} | ||
} | ||
for(int i = 0; i<N; i++){ | ||
for(int j = 0; j<N; j++){ | ||
B[A[i][j]] = 1; | ||
} | ||
} | ||
for(int i = 1; i<N*N+1; i++){ | ||
if(B[i] >= 2){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
if(B[i] == 0){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
} | ||
int S1 = 0; | ||
int S3 = 0; | ||
for(int i = 0; i<N; i++){ | ||
int S = 0; | ||
int S2 = 0; | ||
S1 += A[i][i]; | ||
S3 += A[i][N-i-1]; | ||
for(int j = 0; j < N; j++){ | ||
S += A[i][j]; | ||
S2 += A[j][i]; | ||
} | ||
if(S != (N*(N*N+1))/2){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
if(S2 != (N*(N*N+1))/2){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
|
||
} | ||
if(S3 != (N*(N*N+1))/2){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
if(S1 != (N*(N*N+1))/2){ | ||
printf("FALSE"); | ||
return 0; | ||
} | ||
printf("TRUE"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
void recursive(int N, int K){ | ||
for(int i=0; i<K; i++) cout<<"____"; | ||
cout << "\"재귀함수가 뭔가요?\"\n"; | ||
if(N == K){ | ||
for(int i=0; i<K; i++) cout<<"____"; | ||
cout << "\"재귀함수는 자기 자신을 호출하는 함수라네\"\n"; | ||
} | ||
else{ | ||
for(int i=0; i<K; i++) cout<<"____"; | ||
cout << "\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.\n"; | ||
for(int i=0; i<K; i++) cout<<"____"; | ||
cout << "마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.\n"; | ||
for(int i=0; i<K; i++) cout<<"____"; | ||
cout << "그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"\n"; | ||
recursive(N, K+1); | ||
} | ||
for(int i=0; i<K; i++) cout<<"____"; | ||
cout << "라고 답변하였지.\n"; | ||
} | ||
|
||
int main(){ | ||
int N; | ||
cin >> N; | ||
cout << "어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.\n"; | ||
recursive(N,0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
|
||
int N; | ||
cin >> N; | ||
char A[N][5][7]; | ||
for(int i=0; i<N; i++){ | ||
for(int j=0; j<5; j++){ | ||
cin >> A[i][j]; | ||
} | ||
} | ||
|
||
int comp = 0, max = 35; | ||
int F=0, S=0; | ||
|
||
for(int i=0; i<N-1; i++){ | ||
for(int l=i+1; l<N; l++){ | ||
comp = 0; | ||
for(int j=0; j<5; j++){ | ||
for(int k=0; k<7; k++){ | ||
if(A[i][j][k] != A[l][j][k]){ | ||
comp++; | ||
} | ||
} | ||
} | ||
if(comp < max){ | ||
max = comp; | ||
F=i+1; | ||
S=l+1; | ||
} | ||
} | ||
} | ||
cout << F << " " << S; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
string A; | ||
int num = 0; | ||
cin >> A; | ||
int i=0; | ||
while(A[i] != '\0'){ | ||
if(A[i]=='c'){ | ||
if(A[i+1] == '='){ | ||
i++; | ||
} | ||
else if(A[i+1] == '-'){ | ||
i++; | ||
} | ||
} | ||
else if(A[i] == 'd'){ | ||
if(A[i+1] == 'z' && A[i+2] == '='){ | ||
i += 2; | ||
} | ||
else if(A[i+1] == '-'){ | ||
i += 1; | ||
} | ||
} | ||
else if(A[i] == 'l' && A[i+1] == 'j'){ | ||
i++; | ||
} | ||
else if(A[i] == 'n' && A[i+1] == 'j'){ | ||
i++; | ||
} | ||
else if(A[i] == 's' && A[i+1] == '='){ | ||
i++; | ||
} | ||
else if(A[i] == 'z' && A[i+1] == '='){ | ||
i++; | ||
} | ||
i++; | ||
num++; | ||
} | ||
cout << num; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
string s; | ||
cin>>s; | ||
printf("%c%c",s[0],s[-1]); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main(){ | ||
int M, N, U, L, R, D; | ||
char A[101][101] = {}; | ||
char B[201][201] = {}; | ||
scanf("%d%d", &M, &N); | ||
scanf("%d%d%d%d", &U, &L, &R, &D); | ||
for(int i = 0; i < M; i ++){ | ||
scanf("%s", A[i]); | ||
} | ||
for(int i = 0; i < U + D + M; i ++){ | ||
for(int j = 0; j < L + R + N; j ++){ | ||
if((i + j) % 2 == 0){ | ||
B[i][j] = '#'; | ||
} | ||
else{ | ||
B[i][j] = '.'; | ||
} | ||
} | ||
} | ||
for(int i = U; i < M + U; i ++){ | ||
for(int j = L; j < N + L; j ++){ | ||
B[i][j] = A[i-U][j-L]; | ||
} | ||
} | ||
for(int i = 0; i < U + D + M; i ++){ | ||
for(int j = 0; j < L + R + N; j ++){ | ||
printf("%c", B[i][j]); | ||
} | ||
printf("\n"); | ||
} | ||
} |