当前位置:网站首页>"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
2022-07-02 01:43:00 【Bathe in the four seasons】
The first 3 Chapter after class practice answers
P057
#include<stdio.h>
int main(void)
{
/* Statistical characters ( practice 3-4)*/{
int n,i,letter=0,digit=0,count=0,other=0;
char ch;
printf("Enter n:");
scanf("%d",&n);
getchar();
printf(" Input %d Characters :",n);
for(i=1;i<=n;i++)
{
ch=getchar();
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
letter++;
else if(ch>='0'&&ch<='9')
digit++;
else if(ch==' '||ch=='\n')
count++;
else other++;
}
printf("letter=%d,digit=%d,count( Space or car )=%d,other=%d\n",letter,digit,count,other);}
printf("\n");
/* Output leap year ( practice 3-5)*/{
int m=2000,n,y;
printf("Enter n(21 One year in the century ):");
scanf("%d",&n);
printf("21 By the middle of the century %d There are leap years before :",n);
for(y=m;y<=n;y++)
{
if((y%4==0&&y%100!=0)||(y%400==0))
printf("%d\t",y);
else ;
}
}
return 0;
}P064
#include<stdio.h>
int main(void)
{
/* Achievement transformation ( practice 3-7)*/
int score;
printf("Enter score(1~100):");
scanf("%d",&score);
printf(" Enter the percentile score %d The corresponding five point score is :",score);
if(score>=90)
putchar('A');
else if(80<=score)
putchar('B');
else if(70<=score)
putchar('C');
else if(60<=score)
putchar('D');
else putchar('E');
printf("\n\n");
/* Check the unit price of fruit ( practice 3-8)*/
int i,choice;
double price;
printf("[1]appples\n[2]pears\n[3]oranges\n[4]grapes\n[0]exit\n");
for(i=1;i<=5;i++)
{
printf("Enter choice:");
scanf("%d",&choice);
if(choice==0)
break;
else
switch(choice){
case 1:price=3.00;break;
case 2:price=2.50;break;
case 3:price=4.10;break;
case 4:price=10.20;break;
default:price=0;break;
}
printf("price=%.1lf\n",price);
}
return 0;
}边栏推荐
- [IVX junior engineer training course 10 papers to get certificates] 0708 news page production
- 6-3 vulnerability exploitation SSH environment construction
- Cross domain? Homology? Understand what is cross domain at once
- 遊戲思考15:全區全服和分區分服的思考
- We should make clear the branch prediction
- [Floyd] post disaster reconstruction
- 分卷压缩,解压
- Tencent cloud techo youth dream campus trip into Wuhan University
- 【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面
- How can I batch produce the same title for the video?
猜你喜欢

The role of artificial intelligence in network security

Basic concepts of machine learning

KS006基于SSM实现学生成绩管理系统
![[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games](/img/69/44219af52baef20cedec3870147589.jpg)
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games

How to compress video size while adding watermark with one click?

Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)

matlab 使用 audioread 、 sound 读取和播放 wav 文件

Introduction to ffmpeg Lib

Single chip microcomputer -- hlk-w801 transplant NES simulator (III)

开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
随机推荐
MySQL application day02
卷积神经网络(包含代码与相应图解)
Discussion on the idea of platform construction
2022年6月国产数据库大事记
Edge extraction edges based on Halcon learning_ image. Hdev routine
牛客网——华为题库(51~60)
Learning note 24 - multi sensor post fusion technology
New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port
[rust web rokcet Series 1] Hello, world and get, post, put, delete
Memorabilia of domestic database in June 2022
迁移云计算工作负载的四个基本策略
How to compress video size while adding watermark with one click?
城市选择器组件实现原理
No converter found for return value of type: class
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
游戏思考15:全区全服和分区分服的思考
NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
分卷压缩,解压
What are the skills of spot gold analysis?