zoukankan      html  css  js  c++  java
  • 第六章,处语言控制语句:循环

    6.16  编程练习

    3.

    #include <stdio.h>
    int main(void)//
    {
        const ROW=6;
        for(int row=0;row<ROW;row++)
        {
            char ch ='F';
            for(int list=0;list<=row;list++)
            {
            printf("%c",ch);
            ch--;
            }
            printf("
    ");
        }
        return 0;
    }

    4.

    #include <stdio.h>
    int main(void)//
    {
        const ROW=6;
        for(int row=0;row<ROW;row++)
        {
            char ch ='A'+row;
            for(int list=0;list<=row;list++)
            {
            ch+=list;
            printf("%c",ch);
            }
            printf("
    ");
        }
        return 0;
    }

    5.

    #include <stdio.h>
    int main(void)//
    {
        const ROW=6;
        for(int row=0;row<ROW;row++)
        {
            for(int list=0;list<=ROW-row;list++)
            {
                printf(" ");
            }
            char ch ='A';
            for(int list=0;list<=row;list++)
            {
            printf("%c",ch);
            ch++;
            }
            ch ='A'+row;
            for(int list=0;list<row;list++)
            {
            ch--;
            printf("%c",ch);
            }
            printf("
    ");
        }
        return 0;
    }

    6.pow()输出为double类型

    #include <stdio.h>
    #include <math.h>
    int main(void)//
    {
        int upper=0;
        int lower=0;
        printf("please enter the from upper and lower limits");
        scanf("%d%d",&upper,&lower);
        int ROW=upper;
        for(int row=lower;row<ROW;row++)
        {
            printf("%d,%.0f,%.0f
    ",row,pow(2,2),pow(row,3));
        }
        return 0;
    }

     7.

    #include <stdio.h>
    #include <string.h>
    int main(void)//
    {
        char ch[20];
        printf("please enter a word
    ");
        while(scanf("%s",ch)==1)
        {
            for(int list=0;list<strlen(ch);list++)
            {
                printf("%c",ch[strlen(ch)-list-1]);
            }
            printf("
    ");
            printf("please enter a word
    ");
        }
        return 0;
    }

    8.

    #include <stdio.h>
    #include <math.h>
    int main(void)//
    {
        float a=0;
        float b=0;
        printf("please enter two floating point number
    ");
        while(scanf("%f%f",&a,&b)==2)
        {
            printf("%f
    ",(a-b)/(a*b));
            printf("please enter two floating point number
    ");
        }
        return 0;
    }
  • 相关阅读:
    CSS-常用hack
    CSS触发haslayout的方法
    CSS最大最小宽高兼容
    CSS-文字超出自动显示省略号
    [LeetCode][JavaScript]Number of Islands
    [LeetCode][JavaScript]Search a 2D Matrix II
    [LeetCode][JavaScript]Search a 2D Matrix
    [LeetCode][JavaScript]Candy
    [LeetCode][JavaScript]Wildcard Matching
    [LeetCode][JavaScript]Sliding Window Maximum
  • 原文地址:https://www.cnblogs.com/suwencjp/p/12306960.html
Copyright © 2011-2022 走看看