๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ C Programming/๋ˆ„๊ตฌ๋‚˜ ์‰ฝ๊ฒŒ ์ฆ๊ธฐ๋Š” C ์–ธ์–ด ์ฝ˜์„œํŠธ_๊ฐœ์ • 3ํŒ

[๋ˆ„๊ตฌ๋‚˜ ์‰ฝ๊ฒŒ ์ฆ๊ธฐ๋Š” C ์–ธ์–ด ์ฝ˜์„œํŠธ - ๊ฐœ์ • 3ํŒ] 10์žฅ Mini Project ๋ฌธ์ œ ํ’€์ด

by A Lim Han 2023. 1. 23.

# 10์žฅ Mini Project ๋ฌธ์ œ ํ’€์ด

 

 

 

409p_Mini Project)

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

int main()
{
	char plain_text[30] = "";
	int encrypt_key = 0;
	
	printf("ํ‰๋ฌธ: ");
	gets_s(plain_text, 30);

	printf("\n์•”ํ˜ธํ™” ํ‚ค: ");
	scanf_s("%d", &encrypt_key);

	int leng = strlen(plain_text);
	int i = 0;

	while (1)
	{
		if (plain_text[i] == '\0')
		{
			if (i > leng)
			{
				break;
			}
			else
			{
				plain_text[i] == '\0';
			}
		}
		else
		{
			if (plain_text[i] >= 'A' && plain_text[i] <= 'z')
			{
				plain_text[i] += encrypt_key;

				if (plain_text[i] > 'z')
				{
					plain_text[i] -= 26;
				}
			}
		}
		i++;
	}

	printf("\n์•”ํ˜ธ๋ฌธ: %s\n", plain_text);

	return 0;
}

 

 

 

 

410p_Mini Project)

#include <stdio.h>
#include <string.h>
int main()
{
    int cnt = 0;
    char arr[100];

    printf("๋ฌธ์ž์—ด์„ ์ž…๋ ฅํ•˜์‹œ์˜ค: ");
    gets_s(arr, 100);
    
    for (int i = 0; i < strlen(arr); i++)
    {
        cnt++;

        if (arr[i] != arr[i + 1])
        {
            printf("%c%d", arr[i], cnt);
            cnt = 0;
        }
    }

    return 0;
}

์ฐธ๊ณ :  https://codingdojang.com/scode/465?langby=cpp