0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

🔰条件分岐の代入について。 

Last updated at Posted at 2022-12-16

読んで欲しい人!

・未来の自分
・プログラミングを教えている人
→初学者がどのタイミングでモチベが下がるか知って欲しい!

paizaのこのレベルアップ問題集を解いていたら...

もしかして条件分岐の中に代入ってできるのでは?と思って
解答を間違えるのを覚悟して実行したら正解できた!
(エラーが出た時の精神汚染度高い。樹海で彷徨う感じ)

#include <stdio.h>
int main(void)
{
    int array[8] = {4, 0, 5, -1, 3, 10, 6, -8};
    
    // printf("%d",array[0]);
    
    int i;
    int box = 0;
    for(i = 0; i < 8; i++){
        // printf(" %d",array[i]); // 4 0 5 -1 3 10 6 -8

        if(array[i] >= 5){
            
            box += array[i];
            // printf("%d",box);
        }
    }
    
    printf("%d",box);
    
    return 0;
}

今年の6月からプログラミングを学んで条件分岐を書いたら数値を何か出力する!
条件分岐を書いたらprintfする!
printf以外ありえないっしょ!って私の中のギャルが出てくる。笑

絶対printfする!という武器しか持っていなかったけど
代入を条件分岐のニョロかっこ({})の中に書いてみたらその代入の値が判定されることを知ったのでプログラマーのレベルが上がったこの日を記念日とする!
(やったー!)

20221221更新

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?