νμ μΆλ ₯ νλ‘κ·Έλ¨ λ§λ€κΈ° λ―Έμ
#include <stdio.h>
#include <cs50.h>
#include <string.h>
// νμ μ λ°°μ΄μ μ΄μ©ν΄ μ΄κΈ°ν
void get_grade_loop();
string get_grade(int score);
string get_alert(int score);
int* get_grade_table(int scores[9]);
int main(void)
{
int scores_table[9] = {95,90,85,80,75,70,65,60,0};
printf("νμ νλ‘κ·Έλ¨\nμ’
λ£λ₯Ό μνλ©΄ \"999\"λ₯Ό μ
λ ₯\n");
get_grade_loop();
}
// νμ μ
λ ₯ 999 μ
λ ₯κΉμ§ λ°λ³΅
void get_grade_loop()
{
bool condition = true;
while(condition)
{
int score = get_int("μ±μ μ μ
λ ₯νμΈμ (0 ~ 100) : ");
if(score == 999) {
printf("νμ νλ‘κ·Έλ¨μ μ’
λ£ν©λλ€.\n");
condition = false;
} else if(score < 0 || score > 100 ) {
printf("** %s\n",get_alert(score));
} else {
printf("νμ μ %sμ
λλ€.\n",get_grade(score));
}
}
}
// νμμ μ μλ‘ νμ ꡬνκΈ°
string get_grade(int score)
{
if(score >= 95) {
return "A+";
} else if(score >= 90) {
return "A";
} else if(score >= 85) {
return "B+";
} else if(score >= 80) {
return "B";
} else if(score >= 75) {
return "C+";
} else if(score >= 70) {
return "C";
} else if(score >= 65) {
return "D+";
} else if(score >= 60) {
return "D";
} else {
return "F";
}
}
// validation alert λ¬Έμμ΄ μμ±
string get_alert(int score)
{
char s1[80];
sprintf(s1, "%d", score);
strcat(s1," μ±μ μ μ¬λ°λ₯΄κ² μ
λ ₯νμΈμ. λ²μλ 0 ~ 100 μ
λλ€.");
string str = s1;
return str; // μ
λ ₯ λ°μ μ±μ μ ν¨μ± 체ν¬
}
κ·Όλ‘κ³μ½μ μμ± μλ£, μλ₯ μ μΆ λ..! κ±°μ 1λ λκ² μ€λΉνλκ±° κ°μλ° λλμ΄ μμμΌλΆν° μΆκ·Όμ΄λ€.
μ§μ§ κ°λ°μλ€....γ
λ μ΄μ¬ν ν΄μ μ’μ νμμ΄ λμ.
μμμΌκΉμ§ κΌ νλ²μ© μ΄ν΄λ³΄μ!
Netlify QA
TypeScript
Emotion
D3
jest