题解 | #牛的品种排序I#
牛的品种排序I
https://www.nowcoder.com/practice/e3864ed7689d460c9e2da77e1c866dce
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param cows int整型vector
* @return int整型vector
*/
vector<int> sortCows(vector<int>& cows) {
// write code here
int i=0;
int j=0;
int temp;
for(;i<cows.size();i++){
if(cows[i]==0){
temp=cows[i];
cows[i]=cows[j];
cows[j]=temp;
j++;
}
}
return cows;
}
};


