본문 바로가기

전체 글226

[BAEKJOON] No.5622 C언어 다이얼 ​ ​ ​ ​if else를 쓰면 가독성이 더 좋을것같긴 하지만,, #include #include int main(){ char str[16]; int dial[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9,}; int sec = 0; scanf("%s",str); for(int i=0; i 2021. 10. 18.
[BAEKJOON] No.2908 C언어 상수 ​ ​ ​ ​ #include int changeNum(int num){ int n=100,tmp=0; for(int i=0; inum2) printf("%d\n",num1); else printf("%d\n",num2); }; int main(){ int num1,num2; scanf("%d %d",&num1,&num2); num1 = changeNum(num1); num2 = changeNum(num2); max(num1,num2); return 0; } 2021. 10. 18.
[BAEKJOON] No.1152 C언어 단어의 개수 ​ ​ ​ #include #include #define len 1000000 int main(){ char str[len]; int check = 0; //단어의 개수 scanf("%[^\n]",str);//공백포함 문자열 읽기 for(int i=0; i 2021. 10. 18.
[BAEKJOON] No.1157 C언어 단어공부 ​ ​ ​ #include #include int main(){ char str[1000000]; int arr[26]={0,},max=0; scanf("%s",str); for(int i=0; i='a') str[i] -=32; arr[str[i]-'A']++; // 수 저장 } for(int i=1; i0 && arr[max]==arr[i]) { max = -2; //63 ='?' break; } else if(max='a') str[i] -=32; //소문자를 대문자로 바꿔줌 arr[str[i]-'A']++; // 인덱스 0인 'A'부터 인덱스 25인 'Z' 까지 갯수를 세줌 } for(int i=1; i 2021. 10. 18.
[BAEKJOON] No.2675 C언어 문자열 반복 ​ #include #include int main(){ int testcase,repeat; char str[20]; scanf("%d",&testcase); for(int i=0; i 2021. 10. 18.
[BAEKJOON] No.10809 C언어 알파벳 찾기 ​ ​ ​ ​ #include #include int main(){ char str[100]; scanf("%s",str); for(int i=97; i 2021. 10. 18.
[BAEKJOON] No.11720 C언어 숫자의 합 ​ ​ #include int main(){ int n,sum=0; char num[100]; scanf("%d",&n); scanf("%s",num); for(int i=0; i 2021. 10. 18.
[BAEKJOON] No.4344 C언어 평균은 넘겠지 ​ ​ ​ 각 케이스의 평균보다 높은 경우를 비율로 계산해서 출력 #include int main(){ int caseNum,scoreNum; double rate[1000]={0,}; // 비율 저장 scanf("%d",&caseNum); for(int i=0; i 2021. 10. 18.
[BAEKJOON] No.8958 C언어 OX퀴즈 ​ ​ ​문자열 배열도 동적할당해야하는줄알고 사경을 헤매다가 다시생각해보니 필요없어서 호딱 해버림 사실 score동적할당도 필요없이 바로 출력해도 되는데 그냥 해놓음 #include #include //malloc을 위한 함수 #include //strlen(길이)를 위한 함수 int main(){ char arr[80]={0,}; //문자열 받아오는 배열 int n,plus=0,*score; // n(입력할 문자열의 수), plus(O가 연달아 나오는 만큼 점수를 저장), score(총 점수 저장) scanf("%d",&n); score = (int*)malloc(sizeof(int)*n); //총 점수 배열 동적할당 for(int i=0; i 2021. 10. 18.