資源簡介
C++實戰源碼-數組冒泡排序法(入門級實例121).zip
代碼片段和文件信息
//?array.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
int?main()
{
int?ijt;
int?a[10];
//從鍵盤為數組元素賦值
for(i=0;i<10;i++)
{
cout<<“a[“< cin?>>a[i];
}
for(i=0;i<9;i++)
{
for(j=0;j<9-i;j++)
{
if(a[j]?>?a[j+1])
{
t?=?a[j];
a[j]?=?a[j+1];
a[j+1]?=?t;
}
}
}
cout<<“輸出數組:“<<“\n“;
for(i=0;i<10;i++)
{
cout< if((i+1)%3?==?0)
{
cout<<“\n“;
}
}
cout<<“\n“;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????541??2010-07-14?10:21??array\array.cpp
?????文件????????4524??2010-07-14?10:20??array\array.dsp
?????文件?????????535??2010-07-14?10:20??array\array.dsw
?????文件?????????292??2010-07-14?10:20??array\StdAfx.cpp
?????文件?????????769??2010-07-14?10:20??array\StdAfx.h
- 上一篇:C++實戰源碼-指針和數組的常用方法
- 下一篇:C++實戰源碼-輸出字符表情
評論
共有 條評論