사용자:하늘/메모장/docker: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
67번째 줄: 67번째 줄:
'l' 3개'd' 1개
'l' 3개'd' 1개
'l' 3개'o' 2개'd' 1개
'l' 3개'o' 2개'd' 1개
브레인 퍽 : 이름 그대로 보는 사람의 뇌를 '''과부하로 조지려고''' 만든 변태 프로그래밍 언어. <del>ㅋㅋㅋ</del>
브레인 퍽의 포인터를 2개로 늘려놓은 더블퍽이라는 것도 있다. <del>구글에 Doublefuck치고 이미지 보기하면 안된다.</del>

2021년 10월 15일 (금) 23:41 판

#include <stdio.h>
#include <string.h>

void delchars (char *str, char ch)
{
    int len = strlen(str);
    int i = 0;
    while ( i < len )    
    {
        if (str[i] == ch)
        {
           int j = i, width = 0;
            if ( str[i+1] == ch)
                width = 2;
            else
                width = 1;
            while (j < len)
                str[j] = str[j+width], j++;
        }
        i++;
    }
}
int main ( )
{
    char s1[128];
    strcpy(s1, "HelloWorld");
    delchars(s1, 'l');
    printf("[%s]\n", s1); // [HeoWord]
    delchars(s1, 'W');
    printf("[%s]\n", s1); // [Heoord]
}
#include <stdio.h>
#include <string.h>
int findStr (char *str, char *target)
{
    int i = 0;
    int j = 0;
    for ( ; (*target) != '\0' ; i++)
    {
        int count = 0;
        for ( ; (*str) != '\0'; j++)
        {
            if ( *str == *target)
                count++;      
            str++; 
        }
        str = str - j;
        printf("'%c' %d개", *target, count);
        target++;
    }
    printf("\n");
}
int main () {
    char s[128];
    strcpy (s, "Hello,World");
    findStr(s, "Ho");
    findStr(s, "ld");
    findStr(s, "lod");
}

'H' 1개'o' 2개 'l' 3개'd' 1개 'l' 3개'o' 2개'd' 1개

브레인 퍽 : 이름 그대로 보는 사람의 뇌를 과부하로 조지려고 만든 변태 프로그래밍 언어. ㅋㅋㅋ

브레인 퍽의 포인터를 2개로 늘려놓은 더블퍽이라는 것도 있다. 구글에 Doublefuck치고 이미지 보기하면 안된다.