当前位置:网站首页>Introduction to C language (8)
Introduction to C language (8)
2022-07-26 07:39:00 【InfoQ】
1. How many days are there in a year or a month
2012 229#include<stdio.h>
main()
{
int a,b,c;
scanf("%d %d",&a,&b);
switch(b)
{
case 4:
case 6:
case 9:
case 11: c=30;break;
case 2:
if(a%4==0&&a%100!=0||a%400==0)
c=29;
else
c=28;
break;
default:c= 31;
}
printf("%d",c);
} 2. arithmetic
1.0 + 1.02.00#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double x,y;
char op;
scanf("%lf %c %lf",&x,&op,&y);
switch(op){
case'+':printf("%.2f\n",x+y);break;
case'-':printf("%.2f\n",x-y);break;
case'*':printf("%.2f\n",x*y);break;
case'/':if(fabs(y)<1e-10)
printf("Wrong input!\n");
else printf("%.2f\n",x/y);break;
default:printf("Wrong input!\n");
} return 0;
}3. Absolute maximum
1 2 -3-3#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int a,b,c,x,y,z,m;
scanf("%d %d %d",&a,&b,&c);
x=fabs(a);
y=fabs(b);
z=fabs(c);
if (x>=y)
m=a;
else if(y>=z)
m=b;
else
m=c;
printf("%d",m);
return 0;
}4.n Sum the numbers
3
7 3 212#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n,score,sum;
sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&score);
sum+=score;
}
printf("%d",sum);
return 0;
}5. Summation of sequences 1
31.53#include <stdio.h>
#include <stdlib.h>
int main()
{
int i ,n;
double sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+1*1.0/(2*i-1);
}
printf("%.2lf",sum);
return 0;
}边栏推荐
- 2021全球机器学习大会演讲稿
- 如何关闭高位端口
- 【每日一题】919. 完全二叉树插入器
- Parameterization of JMeter performance test using CSV file
- Web page basic label
- keras学习之:获取神经网络中间层的输出结果
- Practice of online question feedback module (XIV): realize online question answering function
- Regular expression rules and common regular expressions
- ShardingSphere数据分片
- Tensorflow learning diary tflearn
猜你喜欢

Command line execution and test report generation of JMeter performance test

WCF 部署在IIS上

ARIMA model for time series analysis and prediction

Now developers are beginning to do testing. Will there be no software testers in the future?

Learning Efficient Convolutional Networks Through Network Slimming

系统架构&微服务

What is bloom filter in redis series?

Comparison and difference between dependence and Association

NLP natural language processing - Introduction to machine learning and natural language processing (3)

Jmeter性能测试之将每次接口请求的结果保存到文件中
随机推荐
PostgreSQL UUID fuzzy search UUID string type conversion SQL error [42883] explicit type casts
Apache dolphin scheduler 2.x nanny level source code analysis, China Mobile engineers uncover the whole process of service scheduling and start
Pycharm common shortcut keys
Configure flask
MySQL之执行计划
一文掌握mysql数据库审计特点、实现方案及审计插件部署教程
博途PLC一阶滞后系统传递函数阶跃响应输出仿真(SCL)
:app:checkDebugAarMetadata 2 issues were found when checking AAR metadata: 2 issues were found when
模型剪枝三:Learning Structured Sparsity in Deep Neural Networks
系统架构&微服务
keras学习之:获取神经网络中间层的输出结果
Comparison and difference between dependence and Association
[daily question 1] 919. Complete binary tree inserter
Shardingsphere data slicing
Deep learning model deployment
DCN (deep cross network) Trilogy
API (common class 2)
With someone else's engine, can it be imitated?
Polymorphism, final and interface
2022.7.22DAY612