Bài tập thực hành phần 4 môn Tin học đại cương | Đại học Bách khoa Hà Nội

Bài tập thực hành phần 4 của Đại học Bách Khoa Hà Nội với những kiến thức và thông tin bổ ích giúp sinh viên tham khảo, ôn luyện và phục vụ nhu cầu học tập của mình cụ thể là có định hướng ôn tập, nắm vững kiến thức môn học và làm bài tốt trong những bài kiểm tra, bài tiểu luận, bài tập kết thúc học phần, từ đó học tập tốt và có kết quả cao cũng như có thể vận dụng tốt những kiến thức mình đã học vào thực tiễn cuộc sống. Mời bạn đọc đón xem!

4.1:




 
  !
 "#$%&&'&
 ##
(
 #))
*
 "#$
(
4.2:
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750





+
"#$,-"-.
##
(
/#
#+))

"#$,-"-.
##
(
"#$0-.
##
(
4.3:



Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750



"#$%&&'&
##
(

1
)
2
(
"#$
(
4.4:



3
3
 3"#$%&&'&

4*3
225607
"
138
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750
"3
3
3"
(
5607
967742
"#$:56079677
(
(
4.5:



;3<===+
::3
<3*3>?**
3
"#$@-#A-
(
3
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750
"#$@-#A-
(
3
="#$=
(

=>23"#$=
(
<=>32+*
"#$=
(
<=>3)/#<2+*
=+>3>/#<2+*
"#$:==+
(
<
"#$)B:>32+2/#><2+2
"#$>B>32+2>/#><2+2
(
##
(
4.6:
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750



-
3=

-

=

"#$%###
##
(
#))
--*
)"1=
(
"#$
(
##
(
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750
4.7:



-
3=

-

=

"#$%###
##
(
#))
--*
)"1=*"1>
(
"#$
(
##
(
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750
4.8:



-
3=

-

=

"#$%###
##
(
#))
--*
)"1=2-
(
"#$
(
##
(
4.9:
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750




3=

=

 =
"#$%###
(
#))
/#)=
(
"#$?
(
##
(
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750
4.10:




3=

=

 =
"#$%###
(
#))
)"1=2
(
"#$?
(
##
(
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)
lOMoARcPSD|36442750
| 1/10

Preview text:

lOMoARcPSD|36442750 4.1: #include int main(){ int i,n,k; k=1; scanf("%d",&n); if(n<0||n>8){ printf("ERROR"); return 0; } for (i=1; i<=n ; i++) k=k*i; printf("%d",k); } 4.2:
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 #include #include int main(){ int n; scanf("%d",&n); if(n<2){
printf("Khong phai so nguyen to"); return 0; } int m=sqrt(n); for (int i=2;i<=m;i++) if (n%i==0){
printf("Khong phai so nguyen to"); return 0; } printf("La so nguyen to"); return 0; } 4.3: #include #include int main (){
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 int n; scanf ("%d", &n); if (n>=1000) { printf("ERROR"); return 0; } int s=0; while (n>0){ s=s+n%10; n=n/10; } printf("%d", s); } 4.4: #include #include int main (){ int a,b; scanf("%d %d",&a,&b);
if(a<0 || b<0) printf("ERROR"); else { int tich=a*b; //UCLN int tmp; while(b!=0){
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 tmp=a%b; a=b; b=tmp; } int UCLN=a; int BCNN = tich/a; printf("%d\n%d",UCLN,BCNN); } } 4.5: #include #include int main() { float a,b,c,z,x,x1,x2;
scanf("%f\n%f\n%f", &a,&b,&c); z=b*b-4*a*c;
if(a==0 && b==0 && c==0) {
printf("Phuong trinh vo so nghiem"); }
else if(a==0 && b==0) {
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750
printf("Phuong trinh vo nghiem"); }
else if(b==0 && c==0) { x=0; printf("%f", x); } else if(a==0) { x=-c/b; printf("%f", x); } else if(z==0) {x=-b/2*a; printf("%f", x); }
else if(z>0) {x1 =((-b + sqrt(z)) / (2*a));
x2 =((-b - sqrt(z)) / (2*a)); printf("%f\n%f", x1,x2); } else if(z<0) {
printf("%f%+lfi\n",-b/2/a,sqrt(-z)/2/a);
printf("%f%-lfi",-b/2/a,-sqrt(-z)/2/a); } return 0; } 4.6:
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 #include #include int main(){ int n,i,gt; double s,x; s=1; gt=1; scanf("%d",&n); scanf("%lf",&x); if(n<=0){ printf("Error"); return 0; }else{ for(i=1;i<=n;i++){ gt=gt*i; s=s+pow(x,i); } printf("%lf",s); } return 0; }
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 4.7: #include #include int main(){ int n,i,gt; double s,x; s=1; gt=1; scanf("%d",&n); scanf("%lf",&x); if(n<=0){ printf("Error"); return 0; }else{ for(i=1;i<=n;i++){ gt=gt*i; s=s+pow(x,i)*pow(-1,i); } printf("%lf",s); } return 0; }
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 4.8: #include #include int main(){ int n,i,gt; double s,x; s=1; gt=1; scanf("%d",&n); scanf("%lf",&x); if(n<=0){ printf("Error"); return 0; }else{ for(i=1;i<=n;i++){ gt=gt*i; s=s+pow(x,i)/gt; } printf("%lf",s); } return 0; } 4.9:
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 #include #include int main(){ int n,i; double s,x; s=0; scanf("%lf",&x); scanf("%d",&n); if(n<1||x<0){ printf("Error"); }else{ for(i=1;i<=n;i++){ s=sqrt(s+x); } printf("%.4lf",s); } return 0; }
Downloaded by v?n ti?n Lê (vantienle525@gmail.com) lOMoARcPSD|36442750 4.10: #include #include int main(){ int n,i; double s,x; s=1; scanf("%lf",&x); scanf("%d",&n); if(n<1||x<0){ printf("Error"); }else{ for(i=1;i<=n;i++){ s=s+pow(x,i)/i; } printf("%.4lf",s); } return 0; }
Downloaded by v?n ti?n Lê (vantienle525@gmail.com)