当前位置:网站首页>C language exercise 2
C language exercise 2
2022-07-27 09:17:00 【ruin987】
25.
#include <stdio.h>
int main ()
{
int n;
scanf("%d",&n);
if(n>=0)
{
if(n>0)
{
printf("sign(%d) = 1\n",n);
else printf("sign(%d) = 0\n",n);
}
}
else printf("sign(%d) = -1\n",n);
return 0;
}
26.
#include<stdio.h>
int main()
{
int arr[3];
scanf("%d %d %d",&arr[0],&arr[1],&arr[2]);
int i;
int index;
int temp;
int j;
for(i=0;i<2;i++)
{
index=i;
temp=arr[i];
for(j=i+1;j<3;j++)
{
if(arr[j]<=arr[index]) index=j;
}
arr[i]=arr[index];
arr[index]=temp;
}
printf("%d->%d->%d\n",arr[0],arr[1],arr[2]);
return 0;
}27.
#include<stdio.h>
int main()
{
int m;
int n;
scanf("%d %d",&m,&n);
int t1=n+n*0.1;
int t2=n+n*0.5;
printf("%d %d\n",t1,t2);
if(m<t1) printf("OK\n");
if(m>=t1&&m<t2)
{
double temp1=(m-n)/(double)n*100.0;
double temp2=temp1-(int)temp1;
int temp;
if(temp2>=0.5) temp=(int)temp1+1;
else temp=(int)temp1;
printf("Exceed %d%%. Ticket 200\n",temp);
}
if(m>=t2)
{
double temp1=(m-n)/(double)n*100.0;
double temp2=temp1-(int)temp1;
int temp;
if(temp2>=0.5) temp=(int)temp1+1;
else temp=(int)temp1;
printf("Exceed %d%%. License Revoked\n",temp);
}
return 0;
}28
边栏推荐
- Huawei machine test question: Martian computing JS
- Huawei machine test question: String transformation minimum string JS
- Primary function t1744963 character writing
- ES6 new - string part
- 罗克韦尔AB PLC 通过RSLinx Classic与PLC建立通信的具体方法步骤
- CUDA Programming -03: thread level
- [acl2020] a novel method of component syntax tree serialization
- HBuilder 微信小程序中运行uni-app项目
- npm install报错 强制安装
- SQL exercise set
猜你喜欢

As a VC, the auction house invested Web3 for the first time

Deep understanding of Kalman filter (1): background knowledge

Restful

【ACL2020】一种新颖的成分句法树序列化方法

Linux Installation and remote connection MySQL records

PVT's spatial reduction attention (SRA)

ES6 new - object part

8 kinds of visual transformer finishing (Part 1)

A survey of robust lidar based 3D object detection methods for autonomous driving paper notes

B tree
随机推荐
ES6 new - function part
Deep understanding of Kalman filter (3): multidimensional Kalman filter
linux安装和远程连接mysql记录
How to optimize the deep learning model to improve the reasoning speed
网易笔试之解救小易——曼哈顿距离的典型应用
Analog library function
The third day of learning C language
5G没能拉动行业发展,不仅运营商失望了,手机企业也失望了
Restful
As a VC, the auction house invested Web3 for the first time
CUDA programming-05: flows and events
The difference between computed and watch
Restful
Summary of traversal methods
Some practical, commonly used and increasingly efficient kubernetes aliases
[C language - zero foundation lesson 9] love and hate in functions
Svg drawing curve
500报错
音乐体验天花板!14个网易云音乐的情感化设计细节
The fourth day of learning C language