博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
20131002国庆作业例3-4,3-5,3-7
阅读量:4542 次
发布时间:2019-06-08

本文共 1211 字,大约阅读时间需要 4 分钟。

3-4

运行结果1

结果2

结果3

#include
int main(void){ double x,y; printf("Enter x:"); scanf("%lf",&x); if(x<0){ y=0; } else if(x<=15){ y=4*x/3; } else{ y=2.5*x-10.5; } printf("f(%.2f)=%.2f\n",x,y); return 0;}

 

3-5

 

#include
int main(void){ double value1,value2; char op; printf("Type in an expression:"); scanf("%lf%c%lf",&value1,&op,&value2); if(op=='+') printf("=%.2f\n",value1+value2); else if(op=='-') printf("=%.2f\n",value1-value2); else if(op=='*') printf("=%.2f\n",value1*value2); else if(op=='/') printf("=%.2f\n",value1/value2); else printf("Unknown operator\n"); return 0;}

 

 3-7

#include
int main(void){ int digit,letter,other; char ch; int i; digit=letter=other=0; printf("Enter 10 characters:"); for(i=1;i<=10;i++){ ch=getchar(); if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')) letter++; else if(ch>='0'&&ch<='9') digit++; else other++; } printf("letter=%d,digit=%d,other=%d\n",letter,digit,other); return 0;}

 

 

转载于:https://www.cnblogs.com/baojunchi/p/3349665.html

你可能感兴趣的文章
MAC和PHY的区别 (转自http://www.cnblogs.com/feitian629/archive/2013/01/25/2876857.html)
查看>>
.net core部署到linux
查看>>
html10个特效(转载)
查看>>
#将相同值输出,取一个值
查看>>
记一次戴尔R730服务器安装centos7.3步骤
查看>>
决策树基础
查看>>
献给程序员之如何与陌生人交谈
查看>>
Python之登录接口
查看>>
【arc074E】RGB Sequence
查看>>
工作3年了才开始有自己的积累
查看>>
使用axios向后端传递数据,后端接收不到?
查看>>
List 去处自定义重复对象方法
查看>>
CoreData的使用-1
查看>>
阿里云安装samba
查看>>
jsonp跨域
查看>>
day1-xml语言
查看>>
有谁知道瑞星在windows登录界面图标按钮是如何放上去的吗
查看>>
Delphi高效的字符串处理
查看>>
消息中间件ActiveMQ、RabbitMQ、RocketMQ、ZeroMQ、Kafka如何选型?
查看>>
带宽的理解
查看>>