1. 성적 예측 시스템
#include <stdio.h>
// 학생 성적을 예측하는 함수
// 출석 30%, 과제 20%, 시험 50% 비율 적용
double predictScore(double attendance,
double assignment,
double exam)
{
return attendance * 0.3 +
assignment * 0.2 +
exam * 0.5;
}
int main()
{
// 학생 데이터
double attendance = 92.0;
double assignment = 87.0;
double exam = 95.0;
// 예측 점수 계산
double result =
predictScore(attendance,
assignment,
exam);
printf("Prediction Score : %.2f\\n",
result);
// 합격 여부 판단
if(result >= 70)
{
printf("PASS\\n");
}
else
{
printf("FAIL\\n");
}
return 0;
}
2. 추천 시스템
#include <stdio.h>
// 콘텐츠 정보 저장 구조체
typedef struct
{
char title[50];
float similarity;
} Content;
int main()
{
// 추천 후보 데이터
Content contents[] =
{
{"C Programming", 0.88},
{"Data Structure", 0.95},
{"Machine Learning", 0.92}
};
// 가장 높은 유사도를 가진 콘텐츠 인덱스
int bestIndex = 0;
// 최대값 탐색
for(int i = 1; i < 3; i++)
{
if(contents[i].similarity >
contents[bestIndex].similarity)
{
bestIndex = i;
}
}
// 추천 결과 출력
printf("Recommended Content\\n");
printf("%s\\n",
contents[bestIndex].title);
return 0;
}
3. AI 챗봇 프로젝트
#include <stdio.h>
#include <string.h>
int main()
{
// 사용자 입력 저장
char input[100];
printf("AI Assistant Started\\n");
// 무한 반복
while(1)
{
printf("\\nYou : ");
// 사용자 입력 받기
fgets(input,
sizeof(input),
stdin);
// 인사말 처리
if(strstr(input, "hello"))
{
printf("Bot : Hello!\\n");
}
// C언어 질문 처리
else if(strstr(input,
"c language"))
{
printf("Bot : C is a powerful language.\\n");
}
// 종료 명령 처리
else if(strstr(input, "exit"))
{
printf("Bot : Goodbye!\\n");
break;
}
// 등록되지 않은 질문
else
{
printf("Bot : I don't understand.\\n");
}
}
return 0;
}