博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C primer Plus 作业第四章
阅读量:4693 次
发布时间:2019-06-09

本文共 2425 字,大约阅读时间需要 8 分钟。

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

/************************************/

/* practice 1   第四章作业         */

/***********************************/

void p4_1()

{

    char name[20];

    char fristName[20];

    printf("Please Enter your name:");

    scanf("%s",name);

    printf("Please Enter your fristname:");

    scanf("%s",fristName);

    printf("%s,%s",name,fristName);

}

 

/************************************/

/* practice 2     第四章作业         */

/***********************************/

void p4_2()

{

     char name[20];

     int len=strlen(name)+3;

     printf("Please Enter your name:");

     printf("%d",len);

     printf("\"%s\"\n",name);

     printf("\"%20s\"\n",name);

     printf("\"%-20s\"\n",name);

     printf("\"%*s\"\n",len,name);

}

/************************************/

/* practice 3     第四章作业         */

/***********************************/

void p4_3()

{

    float num1,num2;

    printf("Please Enter a float number:");

    scanf("%f",&num1);

    printf("a.The input is %.1f or %.1e\n",num1,num1);

    printf("Please Enter other float number:");

    scanf("%f",&num2);

    printf("b.The input is +%.3f or %.3e\n",num2,num2);

}

/************************************/

/* practice 4     第四章作业         */

/***********************************/

void p4_4(void)

{

    float height;

    char name[20];

    printf("Please Enter your height:");

    scanf("%f",&height);

    printf("Please Enter your name:");

    scanf("%s",name);

    printf("%s, you are %f feet tall",name,height);

}

 

/************************************/

/* practice 5     第四章作业         */

/***********************************/

void p4_5(void)

{

    float velocity, size_file, time;

    printf("Please input the download velocity(Mb/s)、The file size:\n");

    scanf("%f,%f",&velocity,&size_file);

    time = size_file*8 / velocity;

    printf("At %.2f megabits per second, a file of %.2f megabytes\n downloads in %.2f seconds",velocity,size_file,time);

}

 

/************************************/

/* practice 6     第四章作业         */

/***********************************/

void p4_6(void)

{

    char lastname[20];

    char firstname[20];

    printf("Please input last-name:");

    scanf("%s",lastname);

    printf("Please input first-name:");

    scanf("%s",firstname);

    printf("%s %s\n",lastname,firstname);

    printf("%*d %*d\n",strlen(lastname),strlen(lastname),strlen(firstname),strlen(firstname));

    printf("********************************************\n");

    printf("%s %s\n",lastname,firstname);

    printf("%-*d %-*d\n",strlen(lastname),strlen(lastname),strlen(firstname),strlen(firstname));

 

}

 

 

int main()

{

    p4_6();

    return 0;

}

转载于:https://www.cnblogs.com/xuxubot/p/9801651.html

你可能感兴趣的文章
【转】IT名企面试:微软笔试题(1)
查看>>
IO流入门-第十章-DataInputStream_DataOutputStream
查看>>
DRF的分页
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
python:open/文件操作
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>
windows live writer 2012 0x80070643
查看>>
tomcat 和MySQL的安装
查看>>
11.5 内部类
查看>>
Cosine Similarity
查看>>
halt和shutdown 的区别
查看>>
git常用操作
查看>>
京东SSO单点登陆实现分析
查看>>
u-boot启动第一阶段
查看>>
MySQL批量SQL插入性能优化
查看>>
定义列属性:null,default,PK,auto_increment
查看>>
用户画像展示
查看>>
C#中StreamReader读取中文出现乱码
查看>>
使用BufferedReader的时候出现的问题
查看>>