Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions caucsejunseo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
| 5์ฐจ์‹œ | 2025.04.02 | ํ | [์š”์„ธํ‘ธ์Šค๋ฌธ์ œ](https://www.acmicpc.net/problem/1158)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/19|
| 6์ฐจ์‹œ | 2025.04.06 | ํ | [์•ต๋ฌด์ƒˆ](https://www.acmicpc.net/problem/14713)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/23|
| 7์ฐจ์‹œ | 2025.04.10 | ๊ทธ๋ฆฌ๋”” | [ํด๋ฆฌ์˜ค๋ฏธ๋…ธ](https://www.acmicpc.net/problem/1343)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/28|
| 8์ฐจ์‹œ | 2025.04.11 | ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ| [ํ‚ค๋กœ๊ฑฐ](https://www.acmicpc.net/problem/5397)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/30|

| 8์ฐจ์‹œ | 2025.04.11 | ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ| [ํ‚ค๋กœ๊ฑฐ](https://www.acmicpc.net/problem/5397)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/30|
| 9์ฐจ์‹œ | 2025.04.30 | ๋ฌธ์ž์—ด | [๋“ฃ๋ณด์žก](https://www.acmicpc.net/problem/1764)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/35|
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LINE 21
#define MAX 500000

typedef struct Nolisten {

char name[LINE];

} Nolisten;

typedef struct Nosee {

char name[LINE];
}Nosee;

typedef struct Nolistenandsee {

char name[LINE];

} Nolistenandsee;

// strcmp ๊ธฐ๋ฐ˜ ๊ตฌ์กฐ์ฒด ๋น„๊ต ํ•จ์ˆ˜
int compare_struct(const void* a, const void* b) {
return strcmp(((Nolisten*)a)->name, ((Nolisten*)b)->name);
}


int main(void) {

int N = 0;
int M = 0;
int count = 0;


scanf("%d", &N);
scanf("%d", &M);
getchar();

//๊ตฌ์กฐ์ฒด ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„ ํ• ๋‹น
Nolisten* nolistenlist = malloc(sizeof(Nolisten) * N);
Nosee* noseelist = malloc(sizeof(Nosee) * M);
Nolistenandsee* nolistenandseelist = malloc(sizeof(Nolistenandsee) * MAX);


//์ž…๋ ฅ๋ฐ›๊ธฐ
for (int i = 0; i < N; i++)
{
fgets(nolistenlist[i].name, LINE, stdin);
nolistenlist[i].name[strcspn(nolistenlist[i].name, "\n")] = '\0'; // ๊ฐœํ–‰ ์ œ๊ฑฐ
}
for (int j = 0; j < M; j++)
{
fgets(noseelist[j].name, LINE, stdin);
noseelist[j].name[strcspn(noseelist[j].name, "\n")] = '\0'; // ๊ฐœํ–‰ ์ œ๊ฑฐ
}

//๋“ฃ๋„๋ณด๋„ ๋ชปํ•œ ๋†ˆ์ธ์ง€ ํ™•์ธ
qsort(nolistenlist, N, sizeof(Nolisten), compare_struct);

for (int j = 0; j < M; j++)
{
Nolisten key;
strcpy(key.name, noseelist[j].name);

Nolisten* found = bsearch(&key, nolistenlist, N, sizeof(Nolisten), compare_struct);
if (found != NULL) {
strcpy(nolistenandseelist[count++].name, key.name);
}
}

qsort(nolistenandseelist, count, sizeof(Nolistenandsee), compare_struct);

// ์ •๋‹ต ์ถœ๋ ฅ
printf("%d\n", count);
for (int i = 0; i < count; i++) {
printf("%s\n", nolistenandseelist[i].name);
}


return 0;
}

// ์‹œ๊ฐ„์ดˆ๊ณผ ์ฝ”๋“œ
/*#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
# include <stdlib.h>
#include <string.h>

#define LINE 21
#define MAX 500000

typedef struct Nolisten {

char name[LINE];

} Nolisten;

typedef struct Nosee {

char name[LINE];
}Nosee;

typedef struct Nolistenandsee {

char name[LINE];

} Nolistenandsee;

int compare_name(const void* a, const void* b) {
const Nolistenandsee* na = (const Nolistenandsee*)a;
const Nolistenandsee* nb = (const Nolistenandsee*)b;
return strcmp(na->name, nb->name);
}

int main(void) {

int N = 0;
int M = 0;
int count = 0;


scanf("%d", &N);
scanf("%d", &M);
getchar();

//๊ตฌ์กฐ์ฒด ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„ ํ• ๋‹น
Nolisten* nolistenlist = malloc(sizeof(Nolisten) * N);
Nosee* noseelist = malloc(sizeof(Nosee) * M);
Nolistenandsee* nolistenandseelist = malloc(sizeof(Nolistenandsee) * MAX);


//์ž…๋ ฅ๋ฐ›๊ธฐ
for (int i = 0; i < N; i++)
{
fgets(nolistenlist[i].name, LINE, stdin);
nolistenlist[i].name[strcspn(nolistenlist[i].name, "\n")] = '\0'; // ๊ฐœํ–‰ ์ œ๊ฑฐ
}
for (int j = 0; j < M; j++)
{
fgets(noseelist[j].name, LINE, stdin);
noseelist[j].name[strcspn(noseelist[j].name, "\n")] = '\0'; // ๊ฐœํ–‰ ์ œ๊ฑฐ
}

//๋“ฃ๋„๋ณด๋„ ๋ชปํ•œ ๋†ˆ์ธ์ง€ ํ™•์ธ
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
if (strlen(nolistenlist[i].name) == strlen(noseelist[j].name))
{
if (strcmp(nolistenlist[i].name, noseelist[j].name) == 0)
{
strcpy(nolistenandseelist[count].name, nolistenlist[i].name);
count++;

}
}
}
}

// ๋“ฃ๋ณด์žก ์ด๋ฆ„ ์ •๋ ฌ
qsort(nolistenandseelist, count, sizeof(Nolistenandsee), compare_name);

// ์ •๋‹ต ์ถœ๋ ฅ
printf("%d\n", count);
for (int i = 0; i < count; i++) {
printf("%s\n", nolistenandseelist[i].name);
}


return 0;
}
*/