문제 풀이 문자열 관련 함수 문제 풀이 RiKang 2018. 1. 3. 03:02 반응형 (0) [BOJ 4999] 아!정답 예시 (클릭)접기 12345678910111213//code by RiKang, weeklyps.com#include <stdio.h>#include <string.h> int main() { char a[1005]; char b[1005]; scanf("%s",a); scanf("%s",b); if(strlen(a)>=strlen(b)) printf("go"); else printf("no"); return 0;}Colored by Color Scriptercs 접기 (1) [BOJ 5026] 박사 과정정답 예시 (클릭)접기 123456789101112131415161718192021222324252627282930//code by RiKang, weeklyps.com#include <stdio.h>#include <string.h> int main() { int n; char a[15]; char b[15]="P=NP"; scanf("%d",&n); while(n--){ scanf("%s",a); if(strcmp(a,b)==0){ // P=NP인 경우 printf("skipped\n"); continue; } int ans=0, ab=0; for(int i=0; i<strlen(a); i++){ if(a[i]=='+'){ ans=ab; ab=0; // +앞의 수가 끝났으므로 초기화 continue; } ab*=10; ab+=a[i]-'0'; // 아스키 코드를 이용해서 숫자를 추출 } ans+=ab; printf("%d\n",ans); } return 0;}Colored by Color Scriptercs 접기 반응형 저작자표시 비영리 변경금지 (새창열림)