Algorithm/CodeUp
1295 : 알파벳 대소문자 변환
B2SIC
2020. 4. 14. 17:59
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <stdio.h> int main(void) { // A: 65, Z: 90, a:97, z: 122 int i; char strData[1000] = {0}; // 입력에 공백이 없다면 scanf를 사용할 수 있다. // 만약 입력에 공백이 있을 경우 gets_s, fgets 등을 사용해야한다. scanf("%s", strData); for(i = 0; strData[i] != '\0'; i++) { if (strData[i] <= 90 && strData[i] >= 65) printf("%c", strData[i] + 32); else if(strData[i] >= 97 && strData[i] <= 122) printf("%c", strData[i] - 32); else printf("%c", strData[i]); } return 0; } | cs |