当前位置:网站首页>作业2020.11.7-8
作业2020.11.7-8
2020-11-09 00:28:00 【TT睡不醒la】
《第2章1-8题》
1.编写一个程序,调用一次 printf(函数,把你的名和姓打印在一行。再调用一次 printf(函数,把你的名和姓分别打印在两行。然后,再调用两次 printf(函数,把你的名和姓打印在一行。输出应如下所示(当然要把示例的内容换成你的名字):
#include<stdio.h>
#include<stdlib.h>
#define NAME"tiantian"
#define SURNAME"sun"
int main(void)
{
printf("%s %s\n",NAME,SURNAME);
printf("%s\n%s\n",NAME,SURNAME);
printf("%s",NAME);
printf("%s\n",SURNAME);
system("pause");
return 0;
}

2.编写一个程序,打印你的姓名和地址
#include<stdio.h>
#include<stdlib.h>
#define NAME"suntiantian"
#define ADDRESS"NO.67 qianshuiwan,Taizhou"
int main(void)
{
printf("%s\n",NAME);
printf("%s\n",ADDRESS);
system("pause");
return 0;
}

3.编写一个程序,把你的年龄转换成天数,并显示年龄和天数,这里不用考虑闰年的问题。
#include<stdio.h>
#include<stdlib.h>
#define DAYS_PER_YEAR 365
int main(void)
{
int age,days;
age = 19;
days=age*DAYS_PER_YEAR;
printf("You age is %d,and It is %d days.\n",age,days);
system("pause");
return 0;
}

4,4.编写一个程序,生成以下输出
For hes a jolly good fellow!
For he 's a jolly good fellow!
For he s a jolly good fellow!
Which nobody can deny!
除 mainO函数外,该程序还要调用两个自定义函数:一个名为 y jolly,用于打印前3条
消息,调用一次打印一条;另一个函数名为deny,打印最后一条消息
#include<stdio.h>
#include<stdlib.h>
int jolly(void);
int deny(void);
int main(void){
jolly();
jolly();
jolly();
deny();
system("pause");
return 0;
}
int jolly(void){
printf("For he's a jolly good fellow!\n");
return 0;
}
int deny(void){
printf("Which nobody can deny!\n");
return 0;
}

5.5.编写一个程序,生成以下输出。
Brazil, Russia, India, China
India, China,
Brazil, Russia
除main函数外,该程序还要调用两个自定义函数:一个名为br(),调用一次打印一次
”Brazil, Russia“;
另一个名为ic(),调用一次打印一次"india,China”。其他功能在 mainO函数
中实现。

6.编写一个程序,创建一个整型变量toes,并将toes设置为10,程序中还要计算toes的两倍和toes的平方。该程序应打印3个值,并分别描述以示区别。
#include<stdio.h>
#include<stdlib.h>
int main(void){
int toes;
toes-10;
printf("The Variable toes = %d.\n",toes);
printf("double toes = %d.\n",2*toes);
printf("toes' square = %d.\n",toes*toes);
system("pause");
return 0;
}

版权声明
本文为[TT睡不醒la]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4741747/blog/4708435
边栏推荐
- AQS 都看完了,Condition 原理可不能少!
- Flink的DataSource三部曲之三:自定义
- How to reduce the resource consumption of istio agent through sidecar custom resource
- The vowels in the inverted string of leetcode
- Decorator (2)
- 非阻塞的无界线程安全队列 —— ConcurrentLinkedQueue
- Introduction and application of swagger
- Linked blocking queue based on linked list
- C + + adjacency matrix
- Web上的分享(Share)API
猜你喜欢

数据库设计:范式与反范式

Execution of SQL statement

服务器性能监控神器nmon使用介绍

上线1周,B.Protocal已有7000ETH资产!

Fiddler can't grab requests from browsers like Google_ Solution

The interface testing tool eolinker makes post request

分库分表的几种常见玩法及如何解决跨库查询等问题

Flink's datasource Trilogy 3: customization

How does semaphore, a thread synchronization tool that uses an up counter, look like?

STS安装
随机推荐
链表
Factory Pattern模式(简单工厂、工厂方法、抽象工厂模式)
AQS 都看完了,Condition 原理可不能少!
How to make scripts compatible with both Python 2 and python 3?
老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”
Have you ever thought about why the transaction and refund have to be split into different tables
Programmers should know the URI, a comprehensive understanding of the article
LeetCode-11:盛水最多的容器
Aprelu: cross border application, adaptive relu | IEEE tie 2020 for machine fault detection
App crashed inexplicably. At first, it thought it was the case of the name in the header. Finally, it was found that it was the fault of the container!
Programmers should know the URI, a comprehensive understanding of the article
14. Introduction to kubenetes
RabbitMQ快速入门详解
对象
Web上的分享(Share)API
选择API管理平台之前要考虑的5个因素
Five design patterns frequently used in development
写时复制集合 —— CopyOnWriteArrayList
APReLU:跨界应用,用于机器故障检测的自适应ReLU | IEEE TIE 2020
APP 莫名崩溃,开始以为是 Header 中 name 大小写的锅,最后发现原来是容器的错!