By GokiSoft.com|
20:13 04/01/2022|
Lập Trình C
[Lập Trình C] Kết Quả Thi Thực Hành
Kết Quả Thi Thực Hành
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Đặng Trần Nhật Minh [T2008A]](https://www.gravatar.com/avatar/ee8dc5a777ad26f3a962e86c233437cf.jpg?s=80&d=mm&r=g)
Đặng Trần Nhật Minh
2020-10-02 08:21:09
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int isPrime(int n) {
if (n < 2) return 0;
for (int i = 2; i <= sqrt(n); i++)
if (n % i == 0) return 0;
return 1;
}
int main() {
int n;
printf("\nEnter n: ");
scanf("%d", &n);
printf("%d", isPrime(n));
return 0;
}
![hainguyen [T2008A]](https://www.gravatar.com/avatar/32855ce6db55d60134d830aee06b41e5.jpg?s=80&d=mm&r=g)
hainguyen
2020-10-02 08:20:33
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
// Exercise 1.
void isPrime(int n) {
int i;
int num = 1;
if(n==1)
printf("\nE");
else{
for(i=2; i<=sqrt(n); i++){
num = 1;
if(n%i==0){
num = 0;
}
}
if(num==1){
printf("\n%d la so nguyen to.", n);
}else{
printf("\n%d khong phai la so nguyen to.", n);
}
}
}
int main(int argc, char *argv[]) {
int n;
printf("\nNhap n: ");
scanf("%d", &n);
isPrime(n);
return 0;
}
![Đặng Trần Nhật Minh [T2008A]](https://www.gravatar.com/avatar/ee8dc5a777ad26f3a962e86c233437cf.jpg?s=80&d=mm&r=g)
Đặng Trần Nhật Minh
2020-10-02 08:20:04
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void swap(int &a, int &b) {
int temp = a; a = b; b = temp;
}
int isPrime(int n) {
if (n < 2) return 0;
for (int i = 2; i <= sqrt(n); i++)
if (n % i == 0) return 0;
return 1;
}
int main() {
int n, m;
printf("\nPlease Enter n, m: ");
scanf("%d%d", &n, &m);
printf("\nThe prime numbers between %d and %d: ", n, m);
if (n > m) swap(n, m);
bool check = false;
for (int i = n; i <= m; i++)
if (isPrime(i)) printf("\n%d", i), check = true;
if (!check) printf("\nThere are no prime numbers.");
return 0;
}
![Trần Văn Lâm [T2008A]](https://www.gravatar.com/avatar/cfc15c8cb7781ad669b013e01f9f1a6b.jpg?s=80&d=mm&r=g)
Trần Văn Lâm
2020-10-02 08:17:51
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//BAI SO 1:
int main(int argc, char *argv[]) {
int a;
printf("\nNhap so a=");
scanf("%d", &a);
if(a < 2){
printf("\nDay khong phai la so nguyen to.", a);
return 0;
}else{
int i;
int sum = 1;
for(i = 2;i <= sqrt(a);i++){
if(a%i == 0){
sum++;
}
}
if(sum = 1){
printf("\nDay la so nguyen to:%d", a);
}else{
printf("\nDay khong phai la so nguyen to:%d", a);
}
}
return 1;
}
![An Văn Minh [T2008A]](https://www.gravatar.com/avatar/e0f14efe4b11f7d9d5901e8802319c92.jpg?s=80&d=mm&r=g)
An Văn Minh
2020-10-02 08:16:51
//Exercise1:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int isPrime(int number){
if(number<2){
printf("\nThere is no prime number!");
return 0;
}
int count=0;
for(int i=2;i<=sqrt(number);i++){
if(number%i==0){
count++;
}
}
if(count==0){
printf("\nThis is the prime number");
return 1;
}else{
printf("\nThis is not the prime number");
return 0;
}
}
int main(){
int number;
printf("\nEnter number to check: ");
scanf("%d", &number);
isPrime(number);
return 0;
}
![Đỗ Mạc Nam [T2008A]](https://www.gravatar.com/avatar/1935afd10c12c817a4c2882828a07d83.jpg?s=80&d=mm&r=g)
Đỗ Mạc Nam
2020-10-02 08:12:23
#songuyento.cpp
#include <stdio.h>
#include <math.h>
int main()
{
bool IsPrime(int n)
int n;
printf("\nNhap n = ");
scanf("%d", &n);
if(n < 2)
{
printf("\n%d Khong phai so nguyen to", n);
return 0;
}
int count = 0;
for(int i=2; i<=sqrt(n); i++)
{
if(n % i == 0){
count++;
}
}
if(count == 0)
{
printf("\n%d la so nguyen to", n);
}else
{
printf("\n%d hong phai so nguyen to", n);
}
}
![Nguyễn Tuấn Hùng [T2008A]](https://www.gravatar.com/avatar/74c1ca6934aee629f926008762ab4ef5.jpg?s=80&d=mm&r=g)
Nguyễn Tuấn Hùng
2020-10-02 08:03:10
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
typedef int So_nguyen;
int main(int argc, char *argv[]) {
int n, i;
printf("\nNhap n = ");
scanf("%d", &n);
if(n<2) {
printf("\n%d khong phai la so nguyen to", n);
}
int count=0;
for(i=2;i<=sqrt(n);i++) {
if(n%i==0) {
count++;
}
}
if(count==0) {
printf("\n%d la so nguyen to", n);
} else {
printf("\n%d khong phai la so nguyen to", n);
}
return 0;
}
![Đỗ Mạc Nam [T2008A]](https://www.gravatar.com/avatar/1935afd10c12c817a4c2882828a07d83.jpg?s=80&d=mm&r=g)
Đỗ Mạc Nam
2020-10-02 07:56:05
So nguyen to
#include <stdio.h>
#include <math.h>
int main()
{
int n;
printf("\nNhap n = ");
scanf("%d", &n);
if(n < 2)
{
printf("\n%d Khong phai so nguyen to", n);
return 0;
}
int count = 0;
for(int i=2; i<=sqrt(n); i++)
{
if(n % i == 0){
count++;
}
}
if(count == 0)
{
printf("\n%d la so nguyen to", n);
}else
{
printf("\n%d Khong phai so nguyen to", n);
}
}