当前位置:网站首页>C语言练习2
C语言练习2
2022-07-17 05:04: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
边栏推荐
猜你喜欢

游玩数据获取与数据分析、数据挖掘 【2022.5.30】

Restclient operation document

pygame安装-Requirement already satisfied问题

CVE-2020-10199 Nexus Repository Manager3远程命令执行漏洞复现
![[batch] batch delete intermediate folder - personal research script](/img/6d/699987559bc25998e635a403d9d52d.png)
[batch] batch delete intermediate folder - personal research script

ModelArts第二次培訓筆記

User login - and create SMS verification code

Cve-2021-44228 log4j reproduction and principle

Cve-2020-10199 recurrence of nexus repository manager3 remote command execution vulnerability

数据可视化
随机推荐
数据可视化
02_ Movie recommendation (contentbased)_ User portrait
消息转换器(json)
【C】张梁计算器
Microservice high concurrency service governance
Redis installation
mysql数据库实验实训6,数据视图(详细)
Desensitization field example
简单快速建立pytorch环境YOLOv5目标检测 模型跑起来(超简单)
Sleuth getting started
pygame安装-Requirement already satisfied问题
数据分析与数据挖掘实战案例本地房价预测(716):
Differences and precautions of fastjson, jackjson and gson
Swagger's pit
Asynchronous data SMS verification code
读论文《SNUNet-CD: A Densely Connected Siamese Network for Change Detection of VHR Images》
Implementation idea of log adding to database
RestAPI
User - registration / login
User management - restrictions