합격자 평균 구하는 프로그램합격자 평균 구하는 프로그램
Posted at 2013. 12. 2. 15:19 | Posted in 2학기/C언어#include <stdio.h>
#define N 5
double computer_ave(int ary[N]);
int main()
{
int i;
int pass = 0, sum = 0;
int score[N] = {93, 82, 49, 55, 75};
printf("전체 평균: %.1lf \n", computer_ave(score));
for (i=0; i<N; i++)
{
if (score[i] >= 60)
{
sum += score[i];
pass++;
}
}
printf("합격자 평균 : %.1lf \n", (double)sum/pass);
return 0;
}
double computer_ave(int ary[N])
{
int i, sum = 0;
for (i=0; i<N; i++)
sum += ary[i];
return (double)sum / N;
}
'2학기 > C언어' 카테고리의 다른 글
msvcr100d.dll 오류 (0) | 2013.12.11 |
---|---|
키 평균내는 프로그램 (1) | 2013.12.02 |
비밀번호 3번초과시 오류출력하는 프로그램 (1) | 2013.11.25 |
8장 17번 (0) | 2013.11.24 |
8장 16번 (0) | 2013.11.24 |
'2학기 > 플래시' 카테고리의 다른 글
움직이는 편지만들기 (0) | 2013.11.09 |
---|---|
플래시 요소의 종류와 특징 (0) | 2013.10.09 |
플래시 요소의 종류와 특징 (0) | 2013.10.09 |
플래시 (0) | 2013.10.09 |
Tools 패널 (0) | 2013.09.08 |
비밀번호 3번초과시 오류출력하는 프로그램비밀번호 3번초과시 오류출력하는 프로그램
Posted at 2013. 11. 25. 17:09 | Posted in 2학기/C언어#include <stdio.h>
#include <stdlib.h>
#define SUCCESS 1
#define FAIL 2
#define LIMIT 3
int check(int id, int password);
int main(void)
{
int id, password, result;
while(1)
{
printf("id:____\b\b\b\b");
scanf("%d", &id);
printf("pass:____\b\b\b\b");
scanf("%d", &password);
result = check(id, password);
if(result==SUCCESS) break;
}
printf("로그인 성공\n");
return 0;
}
int check(int id, int password)
{
static int super_id = 1234;
static int super_password = 5678;
static int try_count = 0;
try_count++;
if(try_count >=LIMIT)
{
printf("횟수 초과\n");
exit(1);
}
if(id == super_id && super_password == password)
return SUCCESS;
else
return FAIL;
}
'2학기 > C언어' 카테고리의 다른 글
키 평균내는 프로그램 (1) | 2013.12.02 |
---|---|
합격자 평균 구하는 프로그램 (0) | 2013.12.02 |
8장 17번 (0) | 2013.11.24 |
8장 16번 (0) | 2013.11.24 |
8장 15번 (0) | 2013.11.24 |