![닫기](/images/btn_preview_full_close.gif)
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
![](/images/btn_preview_full_left.png)
![](/images/btn_preview_full_right.png)
본문내용
문제 15. 경시 대회 점수판(Contest Scoreboard)
#include
#include
#define Max_Team 100
int main()
{
int Num_case, Team, PB,Time, Type; // 케이스, 팀, 문제, 시간, 타입
int scoreBoard[2][Max_Team]={0};
FILE *file = fopen("test.txt", "r");
if (file == NULL)
return 1;
char c=1;
fscanf(file, "%d", &Num_case);
while(Num_case--)
{
while(1)
{
fscanf(file, "%d %d %d %c", &Team, &PB, &Time, &Type);
fgetc(file);
c = fgetc(file);
switch(Type)
{
case 'I': // time ++
{
scoreBoard[1][Team] += 20;
break;
}
case 'C':
{
scoreBoard[0][Team]++;
scoreBoard[1][Team]+= Time;
break;
}
}
if(feof(file)!=0 || c=='\n')
break;
fseek(file, -1, SEEK_CUR);
}
printf("\n");
// 출력 초기화 같이 같이
for(int i=0; i
if(scoreBoard[0][i] != 0)
{
printf("%d %d
scoreBoard[0][i] = 0;
scoreBoard[1][i] = 0;
}
}
system("pause");
}
문제 16. 야찌(Yahtzee)
문제 17. WERTYU
#include
#define MaxLen 80
char *keyBoard[4] = {"1234567890-=", "QWERTYUIOP[]", "ASDFGHJKL;'", "ZXCVBNM,./"};
char cvtChar(char c);
int main()
{
int i, j;
char str[MaxLen] = {""};
FILE *file = fopen("test.txt", "r");
if(file == NULL)
return 1;
while(feof(file)==0)
{
char c;
for(i=0; (c=fgetc(file))!='\n' && feof(file)==0 ; i++)
{
putc(cvtChar(c), stdout);
}
}
getchar();
}
char cvtChar(char c)
{
for(int i=0; i<4 ; i++)
for(int j=0; (keyBoard[i][j])!='\0'; j++)
if(c == keyBoard[i][j])
return keyBoard[i][j-1];
if( c == ' ' )
return ' ';
return -1;
}
#include
#include
#define Max_Team 100
int main()
{
int Num_case, Team, PB,Time, Type; // 케이스, 팀, 문제, 시간, 타입
int scoreBoard[2][Max_Team]={0};
FILE *file = fopen("test.txt", "r");
if (file == NULL)
return 1;
char c=1;
fscanf(file, "%d", &Num_case);
while(Num_case--)
{
while(1)
{
fscanf(file, "%d %d %d %c", &Team, &PB, &Time, &Type);
fgetc(file);
c = fgetc(file);
switch(Type)
{
case 'I': // time ++
{
scoreBoard[1][Team] += 20;
break;
}
case 'C':
{
scoreBoard[0][Team]++;
scoreBoard[1][Team]+= Time;
break;
}
}
if(feof(file)!=0 || c=='\n')
break;
fseek(file, -1, SEEK_CUR);
}
printf("\n");
// 출력 초기화 같이 같이
for(int i=0; i
{
printf("%d %d
scoreBoard[0][i] = 0;
scoreBoard[1][i] = 0;
}
}
system("pause");
}
문제 16. 야찌(Yahtzee)
문제 17. WERTYU
#include
#define MaxLen 80
char *keyBoard[4] = {"1234567890-=", "QWERTYUIOP[]", "ASDFGHJKL;'", "ZXCVBNM,./"};
char cvtChar(char c);
int main()
{
int i, j;
char str[MaxLen] = {""};
FILE *file = fopen("test.txt", "r");
if(file == NULL)
return 1;
while(feof(file)==0)
{
char c;
for(i=0; (c=fgetc(file))!='\n' && feof(file)==0 ; i++)
{
putc(cvtChar(c), stdout);
}
}
getchar();
}
char cvtChar(char c)
{
for(int i=0; i<4 ; i++)
for(int j=0; (keyBoard[i][j])!='\0'; j++)
if(c == keyBoard[i][j])
return keyBoard[i][j-1];
if( c == ' ' )
return ' ';
return -1;
}
소개글