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 3 years have passed since last update.

プログラミング講座 第三回 「Cで図形を表示しよう」

0
Posted at

環境テスト

hello.c
#include <stdio.h>

int main(void){
    printf("hello\n");
    return 0;
}

0:00-0:30

kuku.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            printf("%4d",i*j);
        }
        printf("\n");
    }
    return 0;
}

0:30-4:45

for1.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        printf("hello\n");
    }
    return 0;
}

4:45-36:40

for2.c
#include <stdio.h>

int main(void){
    int i;
    for(i=0;i<10;i++){
        printf("for %d\n",i);
    }
    printf("%d\n",i);
    return 0;
}

36:40-55:50

kuku.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            printf("%4d",i*j);
        }
        printf("\n");
    }
    return 0;
}

55:50-64:52

asu.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(i%2==0){
                printf("*");
            }else{
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}

やってみよう

ad1.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(i*j%2==0){
                printf("*");
            }else{
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}
ad2.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(i*j%3==0){
                printf("*");
            }else{
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}
ad3.c
#include <stdio.h>

int main(void){
    int i,j;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(j<i){
                printf("*");
            }else{
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}

数字や不等号、printfを少し変えるだけでめちゃくちゃおもしろいものが出来るのでぜひ!

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?