华为机试C语言-最远足迹
题目描述:https://pycoder.blog.csdn.net/article/details/125531902
https://blog.csdn.net/weixin_44052055/article/details/123945932
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>int res_max;int isLegal(char *p)
{return (p[0] == '0' ? 0 : 1);
}int getDistance(int x, int y)
{return ((x * x) + (y * y));
}void coordinatesHandler(char *p, int start, int end, int *x, int *y)
{char tmp[100] = {0};char *data;int xx, yy;strncpy(tmp, p + start, end - start + 1);data = strtok(tmp, ",");if (!isLegal(data)) return;xx = atoi(data);data = strtok(NULL, ",");if (!isLegal(data)) return;yy = atoi(data);if (getDistance(xx, yy) > res_max) {*x = xx;*y = yy;res_max = getDistance(xx, yy);}
}int main(void)
{int len;char str[1000] = {0};int res_x = 0;int res_y = 0;res_max = 0;gets(str);len = strlen(str);int start, end;for (int i = 0; i < len; i++) {if (str[i] == '(') {start = i;} else if (str[i] == ')') {end = i;coordinatesHandler(str, start + 1, end - 1, &res_x, &res_y);}}printf("(%d,%d)\n", res_x, res_y);return 0;
}
华为机试C语言-最远足迹相关推荐
- 华为机试C语言-找到比自己强的人数
题目描述:https://pycoder.blog.csdn.net/article/details/127216746?spm=1001.2014.3001.5502 https://blog.cs ...
- 华为机试C语言-服务失效判断
题目描述:https://zhuanlan.zhihu.com/p/526678876 https://blog.csdn.net/weixin_39765576/article/details/12 ...
- 华为机试C语言-VLAN资源池
题目描述:https://pycoder.blog.csdn.net/article/details/125175834 #include <stdio.h> #include <s ...
- 华为机试C语言-整形数组按个位值排序
题目描述:https://pycoder.blog.csdn.net/article/details/124600540 #include <stdio.h> #include <s ...
- 华为机试C语言-组成最大数
题目描述:https://pycoder.blog.csdn.net/article/details/125923027 想不到这也是一道qsort的题目~ #include <stdio.h& ...
- 华为机试C语言-Words重量
题目描述:https://pycoder.blog.csdn.net/article/details/124743820 #include <stdio.h> #include <s ...
- 华为机试C语言-篮球比赛
题目描述:https://pycoder.blog.csdn.net/article/details/125270003?spm=1001.2014.3001.5502 动态规划 : dp[i] 表示 ...
- 华为机试C语言-一个正整数到Excel编号之间的转换
题目描述:https://blog.csdn.net/qq_23934063/article/details/124676929 #include <stdio.h> #include & ...
- 华为机试C语言-欢乐的周末
题目描述:https://pycoder.blog.csdn.net/article/details/125401136 递归,回溯的时候要考虑周全,不然白理解了. #include <stdi ...
最新文章
- Java 基础【08】.class getClass () forName() 详解
- Spark详解(十二):Spark Streaming原理和实现
- 【读书笔记-数据挖掘概念与技术】分类:高级方法
- Scrapy中的splash的安装应用
- [BZOJ 1150] 数据备份
- 构建高性能.NET应用之配置高可用IIS服务器-第三篇 IIS中三个核心组件的讲解(上)
- Java 128陷阱+自动装箱拆箱
- 数组(Array)的常用方法
- servlet实现新闻控制
- 【PyCharm】Pycharm使用技巧
- android之activety生命周期
- 【练习8.7】cvGoodFeaturesToTrack确定图像强角点、cvFindCornerSubPix亚像素级角点检测...
- Linux7.2虚拟机连接电脑相关配置
- 【7.24校内交流赛】T3【qbxt】复读警告
- Junos: 使用之前
- python计算公司销售额的同比增长率
- 2021年大庆高考成绩查询,2021年大庆高考状元是谁分数多少分,历年大庆高考状元名单...
- 网卡不叫eth0,而叫ens33、ens160、eno1 or enp0s*?
- dom4j读取xml
- Flutter使用插件flutter_staggered_grid_view实现分页瀑布流效果
热门文章
- 贵州华芯通半导体驻北京研发中心开业
- 使用python Mayavi 绘制矢量场图
- 毕业一年经历两次大裁员......
- 这5款微信小程序,实用又不占内存!
- 空间大数据相关的技术
- 小爱同学语音API(不需要小米账号)
- [UE5蓝图基础一]13.类似”人类一败涂地”掉落一定距离会回到空中 最终着落点还是设定地形上
- 电子竞技作为一项全新的竞技体育项目,近年来发展迅猛,未来发展趋势
- 玩转f#的一个实例——解拼图游戏
- 【4月比赛合集】19场可报名的「创新应用」和「程序设计」大奖赛,任君挑选!