문제
string에 있는 문자열 중 소문자 'i'를 대문자 'I'로 변경하는 프로그램을 작성하시오.
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
|
#include<stdio.h>
#include<Windows.h>
#include <time.h>
#include <stdlib.h>
int change(int check);
int main(void) {
srand(time(0));
int ary[30];
int temp;
int i;
for (i = 0; i < sizeof(ary) / sizeof(int); i++) {
temp = rand() % 2;
if(temp == 0) ary[i] = (rand() % 26)+65; // 대문자
else ary[i] = (rand() % 26) + 97;//소문자
ary[i] = change(ary[i]);
}
for (i = 0; i < sizeof(ary) / sizeof(int); i++) {
if ((i % 10) == 0) printf("\n");
printf("%c ", ary[i]);
}
system("pause");
return 0;
}
int change(int check) {
int result = check;
if (check == 105) {
printf("%c -> ", result);
result = 73;
printf("%c\n", result);
}
return result;
}
| cs |
댓글
댓글 쓰기