跟着网课学习,然后整理了自己学习中遇到的一些问题,发的文章算原创么,不太懂这方面的知识。希望有人能帮忙回答一下,谢谢!
算啊,有自己的思路和想法,能自己介绍清楚,如果有引用,在文章最后列出即可。
1 #include <stdio.h>
2 int main()
3 {
4 int a[10] = {2,4,6,8,12,14,15,23,29};
5 int i,j,temp;
6 printf ("Enter an integer:\n");
7 scanf ("%d",&temp);
8
9 if (temp<a[0]) // 如果比a[0]小,则原数组依次向后顺移,补充a[0]为输入的temp
10 {
11 for (i=8;i>=0;i--)
12 {
13 a[i+1] = a[i];
14 }
15 a[0] = temp;
16 }
17 else
18 {
19 for (i=8;i>=0;i--)
20 {
21 if (temp < a[i])
22 {
23 a[i+1] = a[i];
24 }
25 else
26 {
27 a[i+1] = temp;
28 break;
29 }
30 }
31 }
32 for (j=0;j<10;j++)
33 {
34 printf ("%5d",a[j]);
35 }
36 printf ("\n");
37 return 0;
38 }
表明参考出处就行