diff --git a/排序/162.cpp b/排序/162.cpp new file mode 100644 index 0000000..fa3c796 --- /dev/null +++ b/排序/162.cpp @@ -0,0 +1,43 @@ +#include +#include +using namespace std; + +int main(){ + + //定义五本书的价格以及输入五本书的价格 + double a[5],sum,temp; + cout << "请输入五本书的价格:"<> a[i]; + sum += a[i]; + } + + //给这五个数排序我们用冒泡排序 + for(int i=0;i<5;i++){ + + for(int j=0;j<5-i-1;j++){ + + if(a[j]>a[j+1]){ + temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + + } + } + //输入最贵的书,所有书的总价,从低到高输出价格 + + cout << "书的价格从低到高依次是:"<