首页 > 编程语言 > 详细

第六章,处语言控制语句:循环

时间:2020-02-14 13:59:01      阅读:55      评论:0      收藏:0      [点我收藏+]

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("\n");
    }
    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("\n");
    }
    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("\n");
    }
    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\n",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\n");
    while(scanf("%s",ch)==1)
    {
        for(int list=0;list<strlen(ch);list++)
        {
            printf("%c",ch[strlen(ch)-list-1]);
        }
        printf("\n");
        printf("please enter a word\n");
    }
    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\n");
    while(scanf("%f%f",&a,&b)==2)
    {
        printf("%f\n",(a-b)/(a*b));
        printf("please enter two floating point number\n");
    }
    return 0;
}

 

第六章,处语言控制语句:循环

原文:https://www.cnblogs.com/suwencjp/p/12306960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!