mirror of
https://github.com/wahyd4/wahyd4.github.com.git
synced 2026-08-10 22:06:00 +10:00
- 308 posts reverse-extracted from wahyd4.github.com (Hexo 6.3.0 + NexT 8.25) - Hexo project with NexT theme, reading-experience custom styles - publish-post.sh: write post -> hexo build -> PR (master untouched)
36 lines
969 B
Markdown
36 lines
969 B
Markdown
---
|
||
title: "求20个数里面最大的数"
|
||
date: 2010-11-25 00:00:00
|
||
---
|
||
|
||
如题这个应该算是一个超级简单的题吧!以前大一上学期的时候老师就讲过了!
|
||
|
||
这学期,教我们数据结构与算法的老师是从电子科大调过来的副教授!教的真的不错,但是我学的话也明显可以感觉到压力,老师说我们以后还有期中考试要算入期末成绩!这个倒是第一次在我们学校实行!
|
||
|
||
我觉得大家都一样,别人可以做到我也可以做到吧!没什么好怕的。
|
||
|
||
那天,老师在快要下课的时候,叫我们每个人写求20个数里面最大的数的算法!
|
||
|
||
我觉得这个还好吧,就直接用冒泡法?我记得这个算法好像是叫冒泡法。
|
||
|
||
其大致的C语言伪代码就是(这里只写关键的代码):
|
||
|
||
**int temp;**
|
||
|
||
**int a[20];**
|
||
|
||
**for(int i=0;i<20;i++)**
|
||
|
||
**{**
|
||
|
||
**if(a[i]>a[i+1])**
|
||
|
||
**temp=a[i];**
|
||
|
||
**else**
|
||
|
||
**temp=a[i+1];**
|
||
|
||
\*\*
|
||
}\*\*
|