当前位置:网站首页>"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;
}边栏推荐
- No converter found for return value of type: class
- How can I batch produce the same title for the video?
- matlab 使用 audiorecorder、recordblocking录制声音,play 播放声音,audiowrite 保存声音
- 学习笔记2--高精度地图定义及价值
- Parted command
- 基于SSM实现微博系统
- Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
- Cross domain? Homology? Understand what is cross domain at once
- [rust web rokcet Series 2] connect the database and add, delete, modify and check curd
- Learning note 24 - multi sensor post fusion technology
猜你喜欢

开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?

Since I understand the idea of dynamic planning, I have opened the door to a new world
![[Maya] the error of importing Maya into Metahuman](/img/46/46bd1c2d507c9e48ef8c066c54231d.jpg)
[Maya] the error of importing Maya into Metahuman

Convolutional neural network (including code and corresponding diagram)

Learn C language from scratch day 025 (maze)

Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months

What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation

Liteos learning - first knowledge of development environment

GL Studio 5 安装与体验

三分钟学会基础k线图知识
随机推荐
matlab 使用 resample 完成重采样
Number of palindromes in C language (leetcode)
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
uTools
跨域?同源?一次搞懂什么是跨域
人工智能在网络安全中的作用
自动浏览拼多多商品
分卷压缩,解压
LeetCode、3无重复最长子序列
浅浅了解Servlet
Electronic Association C language level 1 33, odd even number judgment
How to compress video size while adding watermark with one click?
Data visualization in medical and healthcare applications
[rust web rokcet Series 1] Hello, world and get, post, put, delete
Android: the kotlin language uses grendao3, a cross platform app development framework
Three core problems of concurrent programming
Brief description of grafana of # yyds dry goods inventory # Prometheus
Luogu p1775 stone merger (weakened version)
成功实现边缘编码需要了解的六大经验教训
TSINGSEE青犀平台如何实现同一节点同时播放多个视频?