Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

TRƯỜNG ĐH SƯ PHẠM KỸ THUẬT TPHCM ĐÁP ÁN CUỐI KỲ HK 1 NĂM HỌC 2020 - 2021

KHOA ĐÀO TẠO CHẤT LƯỢNG CAO Môn: Ngôn ngữ lập trình C
Mã môn học: CPRL130064
Đề số/Mã đề: 13000164

TRẮC NGHIỆM.(4.5 đ)

Phiếu trả lời


Hướng dẫn trả lời câu hỏi:
Chọn câu trả lời đúng: Bỏ chọn: Chọn lại:

STT a b c d STT a b c d
1 X 10 X
2 X 11 X
3 X 12 X
4 X 13 X
5 X 14 X
6 X 15 X
7 X 16 X
8 X 17 X
9 X 18 X

Số hiệu: BM3/QT-PĐBCL-RĐTV- 01 Trang: 1


TỰ LUẬN. (5.5 đ)

Câu 1. ( 1.5 đ)
#include <conio.h>
#include <stdio.h>

int GTCB(float t) 0.25


{
if ( t >= -55.7 && t<= 150)
return 1;
else
return 0;
} 0.25

int main(void)
{
float T;
do
{
scanf("%f",&T); 0.25
}while(GTCB(T) == 0); 0.25

if(T >=22.5 && T<= 32.5)


printf("BINH THUONG\n"); 0.25
else
printf("BAT THUONG \n"); 0.25
getch();
return 0;
}

Câu 2. ( 2.0đ)
#include <conio.h>
#include <stdio.h>
#include <malloc.h>

int main(void)
{

int n;
scanf("%d",&n); 0.25

int *p;
p = (int*)malloc(n*sizeof(int)); 0.25

if(p == NULL)
printf("Khong hop le");
else
{
int i;
printf("Nhap SL san pham bi loi cua n ngay:\n");
for(i = 0; i < n; i++)
scanf("%d",& *(p+i)); 0.25

int m;
m = *p; 0.25
for( i = 1; i < n; i++)
if(m < *(p+i))
m = *(p+i); 0.25

Số hiệu: BM3/QT-PĐBCL-RĐTV- 01 Trang: 2


printf("Nhung ngay co SL san pham bi loi cao nhat:\n");
for( i = 0; i < n; i++)
if( *(p +i) == m) 0.25
printf("Ngay thu %d\n",i);

int k;
k = 0;
for(i = 0; i<n; i++)
if( *(p+i) == 0)
{
k = 1; break;
}
if( k == 1)
printf("Co ngay KHONG CO SP BI LOI\n"); 0.25
else
printf("Khong co ngay KHONG CO SP BI LOI\n"); 0.25

free(p);
}
getch();
return 0;
}

Câu 3. (2.0 đ)
#include <conio.h>
#include <stdio.h>

struct TB
{
int ma;
int tt;
char tenKH[40];
int ngayThue;
int ngayTra;
}; 0.25

int main(void)
{

struct TB a[350]; 0.25


int i, n = 350;

printf("Nhap thong cua cua cac thiet bi:\n");


for( i = 0; i < n; i++)
{
printf("Nhap ttin tbi thu %d\n",i);
scanf("%d",&a[i].ma);
scanf("%d",&a[i].tt);
flushall();
gets(a[i].tenKH);
scanf("%d",&a[i].ngayThue);
scanf("%d",&a[i].ngayTra); 0.25
}
int k = 0;
for(i = 0; i < n; i++)
if(a[i].ma == 151)
if(a[i].tt == 0) 0.25
{
printf("Con TB 151 chua cho thue\n");
printf("Nhap thong tin moi, vi tri thu
%d:\n",i);
scanf("%d",&a[i].tt);

Số hiệu: BM3/QT-PĐBCL-RĐTV- 01 Trang: 3


flushall();
gets(a[i].tenKH);
scanf("%d",&a[i].ngayThue);
scanf("%d",&a[i].ngayTra); 0.25

k = 1; 0.25

break; 0.25
}

if(k == 0)
printf("HET HANG\n"); 0.25

printf("CT ket thuc\n");


getch();
return 0;
}

Ngày 19 tháng 01 năm 2021


Thông qua Trưởng ngành

Số hiệu: BM3/QT-PĐBCL-RĐTV- 01 Trang: 4

You might also like