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;
    }
  • 相关阅读:
    Aspnet_regsql.exe命令行使用小结
    ListView用法学习
    < %=...%>< %#... %>< % %>< %@ %>
    jQuery入门简介
    oracle基础琐碎总结删除数据
    WindowsPhone基础琐碎总结数据绑定(一)
    ADO.NET基础琐碎总结参数化查询
    oracle基础琐碎总结Where和Having的区别与联系
    第一次使用 Windows Live Writer
    WindowsPhone基础琐碎总结数据绑定(二)
  • 原文地址:https://www.cnblogs.com/suwencjp/p/12306960.html
Copyright © 2011-2022 走看看