Created
May 3, 2024 06:50
-
-
Save Huynhnghi/a97923b1d29362a47db99ae8b05b9e55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
// Hàm kiểm tra xem một số có phải là số chính phương hay không | |
int is_chinh_phuong(int num) { | |
int sqrt_num = sqrt(num); | |
return (sqrt_num * sqrt_num == num); | |
} | |
// Hàm đếm số lượng số chính phương nhỏ hơn n và in ra các số đó | |
void dem_so_chinh_phuong(int n) { | |
printf("Cac so chinh phuong nho hon %d la:\n", n); | |
for (int i = 1; i < n; i++) { | |
if (is_chinh_phuong(i)) { | |
printf("%d ", i); | |
} | |
} | |
printf("\n"); | |
} | |
int main() { | |
int n; | |
printf("Nhap so nguyen duong n: "); | |
scanf("%d", &n); | |
dem_so_chinh_phuong(n); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void){ | |
// Your code here! | |
for( int i = 10; i <= 99 ; i++ ) | |
{ | |
if(i % 7 == 0) | |
{ | |
printf("%3d ", i ); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment