result.cpp

来自「学习c++的ppt」· C++ 代码 · 共 23 行

CPP
23
字号
       1:#include <iostream.h>
       2:const int N=10;
       3:
       4:void display(int a[], int n)
       5:{   for(int i = 0; i < n; i ++)  cout << a[i] << "  "; 
       6:    cout << endl;
       7:}
       8:
       9:insert(int a[], int n, int x)
      10:{   int i = 0, j;
      11:    while((x > a[i]) && i < n)  i ++;
      12:	for(j = n-1; j >= i; j --)  a[j] = a[j-1];
      13:    a[i] = x; 
      14:}
      15:
      16:main()
      17:{   int s[N] = {2, 8, 11, 19, 24, 36, 50, 62, 85};
      18:    display(s, N-1);
      19:	insert(s, N, 55);
      20:	display(s, N); 
      21:} 
      22:

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?