c's Introduction
c's People
c's Issues
test
#include <stdio.h>
#include <conio.h>
#include <math.h>
void nhap(int a[]){
for(int i=0; i<10; i++){
printf("Nhap gia tri mang a[%d]: ",i);
scanf("%d",&a[i]);
}
}
void daonguocchieu(int a[]){
for(int i=9; i>=0; i--){
printf("a[%d]= %d\n",i,a[i]);
}
}
void xuat(int a[]){
for(int i=0; i<10; i++){
printf("a[%d]= %d\n",i,a[i]);
}
}
int ptnhonhat(int a[]){
int min = a[0];
for(int i=0; i<10; i++){
if(min > a[i])
min = a[i];
}
return min;
}
void tangdan(int a[]){
int tg;
for(int i=0; i< 9; i++){
for(int j=i+1; j<10; j++){
if(a[i] > a[j]){
tg = a[i];
a[i] = a[j];
a[j] = tg;
}
}
}
}
bool IsPrime(int n)
{
if (n < 2)
return false;
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
void PrintPrime(int a[], int n)
{
for (int i = 0; i < n; i++)
{
if (IsPrime(a[i]))
{
printf("%d\t", a[i]);
}
}
}
int main(){
int a[10];
int n=10;
nhap(a);
printf("--------------------------------\n");
printf("Gia tri nho nhat: %d\n",ptnhonhat(a));
printf("--------------------------------\n");
tangdan(a);
printf("Mang tang dan: \n");
xuat(a);
printf("--------------------------------\n");
printf("Dao nguoc mang: \n");
daonguocchieu(a);
printf("--------------------------------\n");
printf("Cac so nguyen to trong mang: \n");
PrintPrime(a,n);
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.