#include<iostream>
using namespace std;
void paixu(int arr[], int len)
{
for (int i = 0; i < len; i++)
{
int min = arr[i];
for (int j = i+1; j < len; j++)
{
if (arr[i] > arr[j])
{
int temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
}
}
for (int i = 0; i < len; i++)
{
cout << arr[i] << " ";
}cout << endl;
}
void binary(int a)
{
int arr[10] = {0}, i = 0;
while (a >= 2)
{
int b = a % 2;
a = a / 2;
arr[i] = b;
i++;
}
arr[i] = a;
for (int j = i; j >= 0; j--)
{
cout << arr[j];
}cout << endl;
}
int sushu(int n)
{
int i, sum = 0;
for (i = 2; i <= n - 1; i++)
{
if (n % i == 0)
{
sum = sum + 1;
}
}
if (sum == 0)
{
cout << "该数是素数。" << endl;
}
else
{
cout << "该数不是素数。" << endl;
}
return 0;
}
int main()
{
int arr[] = { 20,56,45,892,156,458,623,874,6315 };
int l = sizeof(arr)/4;
int b = 14;
sushu(9);
system("pause");
return 0;
}
|