1.void print_Ar(int* br, int n)
{
for (int i = 0; i < n; ++i)
{
printf("%4d",br[i])
if ((i + 1) % 10 == 0)
{
printf("\n");
}
}
printf("\n");
}
2.
int Findvalue(int br,int n,int val)//index;-1
{ assert(br != NULL);
int pos = -1;
for (int i = 0; i < n;++i)
{
if(br[i]==val)
{
pos = i;
break;
}
}
return pos;
}
3.
#include< iostream >
using namespace std;
void Print(int br[10])
{
int size=sizeof(br);
printf(“size: %d\n”,size);
}
void Init_Ar(intbr,int n)
{
assert(br !=NULL);
for(int i=0;i<n;++i)
{
br[i]=rand()%100+1;
}
}
int main(){}
下面展示一些 内联代码片
。
// A code block
var foo = 'bar';
// An highlighted block
var foo = 'bar';
int main()
{
int p=NULL;
int n=0;
scanf.s("%d",&n);//scanf("%d".&n);cin>>n;
p=new int[n];
//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;
//free ( p);
return 0;
}
5.
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 tmp=rand()%100+1;
if(table [tmp]=0)
{
table [tmp]=1;
br[i]=tmp;
++i;
}
}
}
6.排列方式
int main()
{
const int n=100;
int ar[n]={0};//l.100
//sizeof call;//sizeof(int)*n;
Init_Ar(ar,n);
Print_Ar(ar,n);
BubbleSort(ar,n);
return 0;
}
7.冒泡排列
void BubbleSort (int *br;int n)
{
assert(br!=NULL)
for(int i=1;i<n;++i)
{
for(int j=0;j<n-1;++j)
{
if(br[j]>br[j+1])
{
swap_Int(&br[j],&br[j+1]);
br[j]=br[j+1];
}
}
}
8.交换函数
void swap_Int(int x;int y)
{
int tmp=x;
x=y;
y=tmp;
}
int main()
{ int a=10,b=20;
Swap Int;
}