Bài tập C/C++
Bài tập C/C++
Tuesday, April 1, 2025
Bài tập cơ bản
Bài 20: Liệt kê tất cả "ước số" của số nguyên dương n
Bài 33: Tính S(n) =
Bài 34: Tính S(n) =
Bài 35: Tính S(n) =
Bài 36: Tính S(n) =
Bài 37: Tính S(n) =
Bài 38: Tính S(n) =
Bài 39: Tính S(n) =
Bài 40: Tính S(x,n) =
Bài 41: Tính S(n) =
Bài 46: Hãy đếm số lượng chữ số lẻ của số nguyên dương n
Bài 53: Hãy đếm số lượng chữ số lớn nhất của số nguyên dương n
Bài 65: Giải hệ phương trình bậc nhất 2 ẩn
Bài 66: Tính S(x,n) =
Bài 67: Tính S(x,n) =
Bài 68: Tính S(x,n) =
Bài 69: Tính S(n) =
Saturday, May 14, 2016
Bài 69
Tính S(n) = 
//========================================
//Cach 1
#include <stdio.h>
#include <conio.h>
void main()
{
int n;
printf("n = ");
scanf("%d", &n);
float S = 0;
long M = 0;
float dau = 1;
for (int i=1; i<=n; i++)
{
M = M + i;
S = S + dau*(float)1/M;
dau = -dau;
}
printf("S = %f", S);
}
//========================================
//Cach 2
#include <stdio.h>
#include <conio.h>
float Tong(int);
void main()
{
int n;
printf("n = ");
scanf("%d", &n);
float kq = Tong(n);
printf("S = %f", kq);
}
float Tong(int k)
{
float S = 0;
long M = 0;
float dau = 1;
for(int i=1; i<=k; i++)
{
M = M + i;
S = S + dau*(float)1/M;
dau = -dau;
}
return S;
}
Thursday, May 7, 2015
Bài 68
Tính S(x,n) = 
//========================================
//Cach 1
#include <stdio.h>
#include <conio.h>
void main()
{
float x;
printf("x = ");
scanf("%f", &x);
int n;
printf("n = ");
scanf("%d", &n);
float S = x;
float T = x;
float dau = -1;
for(int i=3; i<=2*n+1; i=i+2)
{
T = T*x*x;
S = S + T*dau;
dau = -dau;
}
printf("S = %f", S);
}
//========================================
//Cach 2
#include <stdio.h>
#include <conio.h>
float Tong(float,float);
void main()
{
float x;
printf("x = ");
scanf("%f", &x);
int n;
printf("n = ");
scanf("%d", &n);
float kq = Tong(x,n);
printf("S = %f", kq);
}
float Tong(float y, float k)
{
float S = y;
float T = y;
float dau = -1;
for(int i=3; i<=2*k+1; i=i+2)
{
T = T*y*y;
S = S + T*dau;
dau = -dau;
}
return S;
}
Tuesday, April 21, 2015
Bài 67
Bài 67: Tính S(x,n) = 
//========================================
// Cach 1
#include <stdio.h>
#include <conio.h>
void main()
{
float x;
printf("x = ");
scanf("%f", &x);
int n;
printf("n = ");
scanf("%d", &n);
float S = 0;
float P = 1;
float dau = -1;
for(int i=2; i<=2*n; i=i+2)
{
P = P*x*x;
S = S + P*dau;
dau = -dau;
}
printf("S = %f", S);
}
//========================================
//Cach 2
#include <stdio.h>
#include <conio.h>
float Tong(float,float);
void main()
{
float x;
printf("x = ");
scanf("%f", &x);
int n;
printf("n = ");
scanf("%d", &n);
float kq = Tong(x,n);
printf("S = %f", kq);
}
float Tong(float y, float k)
{
float S = 0;
float P = 1;
float dau = -1;
for(int i=2; i<=2*k; i=i+2)
{
P = P*y*y;
S = S + P*dau;
dau = -dau;
}
return S;
}
Monday, April 20, 2015
Bài 66
Bài 66: Tính S(x,n) = 
//========================================
// Cach 1
#include <stdio.h>
#include <conio.h>
void main()
{
float x;
printf("x = ");
scanf("%f", &x);
int n;
printf("n = ");
scanf("%d", &n);
float S = 0;
float P = 1;
float dau = 1;
for (int i=1; i<=n; i++)
{
P = P*x;
S = S + dau*P;
dau = -dau;
}
printf("S = %f", S);
}
//========================================
//Cach 2
#include <stdio.h>
#include <conio.h>
float Tong(float,int);
void main()
{
float x;
printf("x = ");
scanf("%f", &x);
int n;
printf("n = ");
scanf("%d", &n);
float kq = Tong(x,n);
printf("S = %f", kq);
}
float Tong(float y, int k)
{
float S = 0;
float P = 1;
float dau = 1;
for (int i=1; i<=k; i++)
{
P = P*y;
S = S + dau*P;
dau = -dau;
}
return S;
}
Subscribe to:
Comments (Atom)
có n dấu căn
có n dấu căn
có n dấu căn
có n dấu căn
có n-1 dấu căn
có n dấu căn
có n dấu căn
có n dấu căn
có n dấu phân số





