?? 2p1.cpp
字號:
/*
NIIT 《C++ & CGI PROGRAMMING &SCRRIPTING》 Skill Base
P2.11 ◆2.P.1◆
Checkup: MrZhou
17:51 2004-09-26
*/
#include <iostream.h>
void sortData();//Forward Declaration
void display(); //Forward Declaration
/* The Array Named amounts Is Defined Globally */
float amounts[10] = {200.5F,323,0,100.7F,314,523,256,10.90F,553.90F,0};
int main()
{
sortData(); //Call The sortdata() Function
display(); //Call The display() Function
return 0;
}
void sortData()
{
int counter=0;
/* Traverse The Array */
while(counter < 9)
{
float temp;
/* Compare The Value Of Current Element With The Next */
if(amounts[counter] < amounts[counter + 1])
{
/* Swap The Values */
temp = amounts[counter];
amounts[counter] = amounts[counter + 1];
amounts[counter + 1] = temp;
counter = 0;
continue;
}
counter++;
}
return;
}
void display()
{
/* Display All The Array Elements */
for(int counter = 0;counter < 10; ++counter)
{
if(amounts[counter] != 0)
{
cout << "Element " << counter << ": "
<< amounts[counter] << endl;
}
}
return;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -