当前位置:网站首页>"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;
}
边栏推荐
- 成功实现边缘编码需要了解的六大经验教训
- Using tabbar in wechat applet
- New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port
- NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
- Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
- Android: the kotlin language uses grendao3, a cross platform app development framework
- Learning note 3 -- Key Technologies of high-precision map (Part 1)
- 机器学习基本概念
- Discussion on the idea of platform construction
- Experimental reproduction of variable image compression with a scale hyperprior
猜你喜欢
Convolutional neural network (including code and corresponding diagram)
How can I batch produce the same title for the video?
Learning notes 25 - multi sensor front fusion technology
Introduction to ffmpeg Lib
Cross domain? Homology? Understand what is cross domain at once
技术大佬准备就绪,话题C位由你决定
Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
现货黄金分析的技巧有什么呢?
【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面
It's already 30. Can you learn programming from scratch?
随机推荐
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
Look at the industrial Internet from a new perspective and seek the correct ways and methods of industrial Internet
Penser au jeu 15: penser au service complet et au sous - service
LeetCode、3无重复最长子序列
Using tabbar in wechat applet
How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?
Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
学习笔记25--多传感器前融合技术
Modeling essays series 124 a simple coding method
Self drawing of menu items and CListBox items
Number of palindromes in C language (leetcode)
Game thinking 15: thinking about the whole region and sub region Services
现货黄金分析的技巧有什么呢?
NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
Matlab uses audioread and sound to read and play WAV files
What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
电子协会 C语言 1级 33 、奇偶数判断
Memorabilia of domestic database in June 2022
卷積神經網絡(包含代碼與相應圖解)