查重函数
#include <iostream>
#include <assert.h>
using namespace std;
void Print_Ar(int* br, int n)
{
for (int i = 0; i < n; ++i)
{
printf("%d", br[i]);
}
printf("\n");
}
int FindValue(int* br, int n, int val)//index:-1
{
assert(br != NULL);
for (int i = 0; i < n; ++i)
{
if (br[i] == val)
{
return i;
}
else
{
return -1;
}
}
}
//1...100
void Init_Ar(int* br, int n)
{
assert(br != NULL);
int* table = new int[n+1];
for (int i = 0; i < n; ++i)
{
table[i] = 0;
}
int i = 0;
while (i < n)
{
int temp = rand() % 100 + 1;
}
}
int main()
{
int* p = NULL;
int n = 0;
scanf_s("%d", &n);//cin>>n;
p = new int[n];//C++
//p=(int*)malloc(sizeof(int)*n);//C
for(int i = 0; i< n; ++i)
{
p[i] = i;
}
for (int i = 0; i < n; ++i) { printf("%d", p[i]); }
delete p;//C++
//free(p);//C
return 0;
}
冒泡排序法:
知识模块:swap()函数、for循环、数组应用
思想基础:
(1)比较相邻的元素,如果这个元素大就往后移;
(2)比较下一组元素;
(3)重复上述操作;
(4)最终结果呈现排序正确;