【解決方法】単語の塗りつぶしを完了します。関数 print_zero_even odd は、ゼロの数と、奇数と偶数の数を出力します。

プログラミングQA


C++
void print_zero_even_odd(_________), int arr_len)
{
   int o=0;, _________;
   for(int i =0; i<arr_len; ++i){
        const int ________;
        if(v==0) ++z;
        if(_______) ++o;
   }
   printf("zeros: %d, odd: %d, even: %d\n", z, o, ______
}

私が試したこと:

and the options are:
1. const int arr[]
2. z=0
3. (v%2)!=0
4. v= arr[i]
5. arr_len-o
6. (v%2)==0 
7. (v%2)! = 3
8. arr_len
9. const int z[]

やってみたけどダメだった

解決策 1

私たちは立ち往生している人々を喜んで助けますが、それは私たちがあなたのためにすべてをするためにここにいるという意味ではありません! 私たちがすべての作業を行うことはできません。あなたはこれに対して報酬を受け取っているか、またはそれはあなたの成績の一部であり、私たちがあなたのためにすべてを行うことはまったく公平ではありません.

だから私たちはあなたが仕事をする必要があり、あなたが行き詰まったときにあなたを助けます. それは、あなたが提出できる段階的な解決策を提供するという意味ではありません!
現在の状況と、プロセスの次のステップを説明することから始めます。 次に、その次のステップを機能させるために何を試みたか、またその際に何が起こったかを教えてください。

開始するのに問題がある場合は、これが役立つ場合があります。 問題を解決するためのコードの書き方、初心者向けガイド[^]

解決策 2

考慮すべき点:

C++
//
// if this function is going to count different items of the input
// then what would you expect to be passed in as the first parameter?

void print_zero_even_odd(_________), int arr_len)
{
   int o=0;, _________; // if o is the count of odds, what other counter would you expect here?
   for(int i =0; i<arr_len; ++i){
        const int ________; // look at the next line, are v and z defined anywhere?
        if(v==0) ++z;
        if(_______) ++o; // how would you test for an odd (or even) number?
   }
printf("zeros: %d, odd: %d, even: %d\n", z, o, ______
}

コメント

タイトルとURLをコピーしました