当前位置:网站首页>"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;
}边栏推荐
- Volume compression, decompression
- matlab 使用 audioread 、 sound 读取和播放 wav 文件
- Penser au jeu 15: penser au service complet et au sous - service
- 6-2漏洞利用-ftp不可避免的问题
- 三分钟学会基础k线图知识
- Number of palindromes in C language (leetcode)
- Game thinking 15: thinking about the whole region and sub region Services
- [image enhancement] vascular image enhancement based on frangi filter with matlab code
- 6-2 vulnerability exploitation - inevitable problems of FTP
- Exclusive delivery of secret script move disassembly (the first time)
猜你喜欢

城市选择器组件实现原理

Since I understand the idea of dynamic planning, I have opened the door to a new world

The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
![[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me](/img/b8/31a498c89cf96567640677e859df4e.jpg)
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me

Learning note 24 - multi sensor post fusion technology

MATLAB realizes voice signal resampling and normalization, and plays the comparison effect

Penser au jeu 15: penser au service complet et au sous - service

Volume compression, decompression

Number of palindromes in C language (leetcode)

Learn basic K-line diagram knowledge in three minutes
随机推荐
卷积神经网络(包含代码与相应图解)
Tencent cloud techo youth dream campus trip into Wuhan University
II Basic structure of radio energy transmission system
MPLS experiment operation
Look at the industrial Internet from a new perspective and seek the correct ways and methods of industrial Internet
Implementation principle of city selector component
Based on configured schedule, the given trigger will never fire
如何用一款产品推动「品牌的惊险一跃」?
城市选择器组件实现原理
uTools
Failed to transform file 'xxx' to match attributes
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production
[IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
Laravel artisan 常用命令
k线图形态这样记(口诀篇)
[Chongqing Guangdong education] Tianshui Normal University universe exploration reference
迁移云计算工作负载的四个基本策略
new和malloc的区别
现货黄金分析的技巧有什么呢?
No converter found for return value of type: class