基于visual Studio2013解决面试题之1402选择排序

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               



题目



解决代码及点评

  1.   
  1.   
  1. <code class="language-cpp">/* 
  2.     选择排序 
  3. */  
  4.   
  5. #include <iostream>  
  6. using namespace std;  
  7.   
  8. int main()  
  9. {  
  10.     int a[10];  
  11.     for (int i = 0; i < 10; i++)  
  12.         a[i] = rand() % 100;  
  13.   
  14.     for (int i = 0; i < 10; i++)  
  15.     {  
  16.   
  17.         for (int j = i; j < 10 - i; j++)  
  18.         if (a[j] < a[i])  
  19.         {  
  20.             int temp = a[j];  
  21.             a[j] = a[i];  
  22.             a[i] = temp;  
  23.         }  
  24.     }  
  25.   
  26.   
  27.     for (int i = 0; i < 10; i++)  
  28.         cout << a[i] << " ";  
  29.     system("pause");  
  30. }</code>  
/* 选择排序*/#include <iostream>using namespace std;int main()int a[10]; for (int i = 0; i < 10; i++)  a[i] = rand() % 100for (int i = 0; i < 10; i++) {  for (int j = i; j < 10 - i; j++)  if (a[j] < a[i])  {   int temp = a[j];   a[j] = a[i];   a[i] = temp;  } } for (int i = 0; i < 10; i++)  cout << a[i] << " "; system("pause");}


代码下载及其运行

代码下载地址:http://download.csdn.net/detail/yincheng01/6704519

解压密码:c.itcast.cn


下载代码并解压后,用VC2013打开interview.sln,并设置对应的启动项目后,点击运行即可,具体步骤如下:

1)设置启动项目:右键点击解决方案,在弹出菜单中选择“设置启动项目”


2)在下拉框中选择相应项目,项目名和博客编号一致

3)点击“本地Windows调试器”运行


程序运行结果








           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
这里写图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值