| 
 
TA的每日心情|  | 开心 2014-6-18 08:29
 | 
|---|
 签到天数: 14 天 [LV.3]偶尔看看II 滴水大师  
 
 
	积分2345 
 | 
 
| 题目 
  
 解决代码及点评
 
 
 
 
 <pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"></pre><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code">/* 10. 写一主函数输入一数组,写一子函数实现对该数组的冒泡排序并输出。 */    #include <stdio.h>  #include <stdlib.h>  const int N=10;  void f610(int *p)//冒泡排序  {      for (int i=0;i<N;i++)      {          for (int j=0;j<N;j++)  // 冒泡比较          {              if (p>p[j])              {                  int temp;                  temp=p;                  p=p[j];                  p[j]=temp;              }          }      }  }  void main()  {        int a[N];      for (int i=0;i<N;i++)  // 初始化数组      {          a=rand();          printf("%d\t",a);      }        f610(a);  // 进行排序        for (int i=0;i<N;i++)   // 输出结果      {          printf("%d\t",a);      }      system("pause");  }</pre><br><br></pre></pre>  
 
 
 | 
 |