Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
41277 老方 整数奇偶排序 C++ 解答错误 1 MS 252 KB 533 2024-02-20 11:17:51

Tests(0/1):


#include<bits/stdc++.h> using namespace std; void sort(int ns[],int len){ for(int i=0;i<len;i++){ for(int j=0;j<len-1-i;j++){ if(ns[j]%2==1){ if(ns[j]<ns[j+1]) swap(ns[j],ns[j+1]); } else if(ns[j]>ns[j+1])swap(ns[j],ns[j+1]); } } } int main(){ int o[10],j[10],oc=0,jc=0,temp; for(int i=0;i<10;i++){ cin>>temp; if(temp%2)j[jc++]=temp; else o[oc++]=temp; } sort(o,o+oc); sort(j,j+jc); for(int i=0;i<jc;i++)cout<<j[i]<<' '; for(int i=0;i<oc;i++)cout<<o[i]<<' '; return 0; }


测评信息: