0$房天下问答|C++中函数问题2(来自昆山优秀小区小区)$https://m.fang.com/ask/ask_1847732.html$https://static.soufunimg.com/common_m/m_public/201511/images/asksharedefault.png
packc/pages/ask/detail/detail?askid=1847732
共1个回答
-
-
-
jessiememory
丨Lv 4
#include <iostream>using namespace std;void fun(int s[],int n,int &x,int &y){ int i,j,k; int temp; for(i=0; i<n-1; i++) { k = i; for(j=i+1; j<n; j++) { if(s[k] < s[j]) { k = j; } } if(k != i) { temp = s[i]; s[i] = s[k]; s[k] = temp; } } for(i=0; i<n; i++) { if(s[i] > 80) { x++; } if(s[i] < 60) { y++; } }} void main(){ int s[10] = {90,50,60,40,85,86,70,55,64,86}; int x=0,y=0; fun(s, 10, x, y); cout<<"排序后:"; for(int i=0; i<10; i++) { cout<<s[i]<<" "; } cout<<"\n优秀人数:"<<x; cout<<"\n不及格人数:"<<y<<endl;}
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。

关注成功