// 按综合成绩排序 void sortDataByTotalGrade(int asc, SeqList* list) { int i; for (i = 0; i < list->length - 1; i++) { int j; for ( j = 0; j < list->length - i - 1; j++) { if ((asc && list->data[j].totalGrade > list->data[j + 1].totalGrade) || (!asc && list->data[j].totalGrade < list->data[j + 1].totalGrade)) { Score temp = list->data[j]; list->data[j] = list->data[j + 1]; list->data[j + 1] = temp; } } } }为这段代码画一个流程图

时间: 2024-04-04 08:35:56 浏览: 12
抱歉,作为语言模型AI,我无法画图。但我可以尝试用文字描述这段代码的流程: 1. 接收两个参数,一个是排序方式(升序/降序),另一个是待排序的数据列表; 2. 使用两个嵌套的循环遍历数据列表,外层循环控制遍历次数,内层循环控制比较和交换; 3. 在内层循环中,如果当前元素与下一个元素的综合成绩比较大小,如果需要交换,则进行交换; 4. 最终得到一个按照综合成绩排序的数据列表。
相关问题

<!DOCTYPE html> <?php require_once('MkEncrypt.php'); MkEncrypt('1234'); //这个就是密码 ?> <html> <head> <meta charset="UTF-8"> <title>GOLA 2.0</title> </head> <style type="text/css"> .wrapper {width: 1000px;margin: 20px auto;} h2 {text-align: center;} .add {margin-bottom: 20px;} .add a {text-decoration: none;color: #fff;background-color: green;padding: 6px;border-radius: 5px;} td {text-align: center;} </style> <body> <div class="wrapper"> <h2>GOLA 2.0</h2> <div class="add"> <!--<a href="adduser.html">增加新闻</a>--> </div> <table width="960" border="1"> <tr> <th>ID</th> <th>用户呀</th> <th>手机呀</th> <th>刷新密码</th> <th>总资</th> <th>可用</th> <th>操作</th> </tr> <?php // 1.导入配置文件 require "dbconfig.php"; // 2. 连接mysql $link = @mysql_connect(HOST,USER,PASS) or die("提示:数据库连接失败!"); // 选择数据库 mysql_select_db(DBNAME,$link); // 编码设置 mysql_set_charset('utf8',$link); // 3. 从DBNAME中查询到user数据库,返回数据库结果集,并按照addtime降序排列 $sql = 'select * from user order by id asc'; // 结果集 $result = mysql_query($sql,$link); // var_dump($result);die; // 解析结果集,$row为新闻所有数据,$userNum为新闻数目 $userNum=mysql_num_rows($result); for($i=0; $i<$userNum; $i++){ $row = mysql_fetch_assoc($result); echo "<tr>"; echo "<td>{$row['id']}</td>"; echo "<td>{$row['agent_name']}</td>"; echo "<td>{$row['phone']}</td>"; echo "<td>{$row['with_pwd']}</td>"; echo "<td>{$row['user_amt']}</td>"; echo "<td>{$row['enable_amt']}</td>"; echo "<td> <a href='javascript:del({$row['id']})'>删除</a> <a href='editnews.php?id={$row['id']}'>修改</a> </td>"; echo "</tr>"; } // 5. 释放结果集 mysql_free_result($result); mysql_close($link); ?> </table> </div> <script type="text/javascript"> function del (id) { if (confirm("确定删除这条新闻吗?")){ window.location = "action-del.php?id="+id; } } </script> </body> </html> 美化一下页面

为了美化页面,我们可以添加一些CSS样式,比如更改背景颜色、字体样式、表格边框等。可以参考下面的代码: ``` <!DOCTYPE html> <?php require_once('MkEncrypt.php'); MkEncrypt('1234'); //这个就是密码 ?> <html> <head> <meta charset="UTF-8"> <title>GOLA 2.0</title> <style type="text/css"> body { background-color: #f2f2f2; font-family: Arial, sans-serif; font-size: 14px; } .wrapper { width: 1000px; margin: 20px auto; background-color: #fff; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px #ccc; } h2 { text-align: center; color: #333; } .add { margin-bottom: 20px; text-align: right; } .add a { text-decoration: none; color: #fff; background-color: green; padding: 6px; border-radius: 5px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th, td { padding: 10px; border: 1px solid #ccc; } th { background-color: #f2f2f2; } td { text-align: center; } td a { text-decoration: none; color: #333; margin-right: 10px; } td a:hover { color: red; } </style> </head> <body> <div class="wrapper"> <h2>GOLA 2.0</h2> <div class="add"> <!--<a href="adduser.html">增加新闻</a>--> </div> <table> <tr> <th>ID</th> <th>用户呀</th> <th>手机呀</th> <th>刷新密码</th> <th>总资</th> <th>可用</th> <th>操作</th> </tr> <?php // 1.导入配置文件 require "dbconfig.php"; // 2. 连接mysql $link = @mysql_connect(HOST,USER,PASS) or die("提示:数据库连接失败!"); // 选择数据库 mysql_select_db(DBNAME,$link); // 编码设置 mysql_set_charset('utf8',$link); // 3. 从DBNAME中查询到user数据库,返回数据库结果集,并按照addtime降序排列 $sql = 'select * from user order by id asc'; // 结果集 $result = mysql_query($sql,$link); // var_dump($result);die; // 解析结果集,$row为新闻所有数据,$userNum为新闻数目 $userNum=mysql_num_rows($result); for($i=0; $i<$userNum; $i++){ $row = mysql_fetch_assoc($result); echo "<tr>"; echo "<td>{$row['id']}</td>"; echo "<td>{$row['agent_name']}</td>"; echo "<td>{$row['phone']}</td>"; echo "<td>{$row['with_pwd']}</td>"; echo "<td>{$row['user_amt']}</td>"; echo "<td>{$row['enable_amt']}</td>"; echo "<td> <a href='javascript:del({$row['id']})'>删除</a> <a href='editnews.php?id={$row['id']}'>修改</a> </td>"; echo "</tr>"; } // 5. 释放结果集 mysql_free_result($result); mysql_close($link); ?> </table> </div> <script type="text/javascript"> function del (id) { if (confirm("确定删除这条新闻吗?")){ window.location = "action-del.php?id="+id; } } </script> </body> </html> ``` 这样,我们就可以得到一个美化后的页面。

这个列表是pol的输入列表你能帮我添加进去么,<select id="pol" name="pol" class="form-control"><option value="CNNSA">NANSHA</option><option value="CNSWA">SHANTOU</option><option value="CNSHA">SHANGHAI</option><option value="CNTXG">TIANJIN XINGANG</option><option value="CNDLC">DALIAN</option><option value="CNTSN">TIANJIN</option><option value="TWTXG">TAICHUNG</option><option value="TWKHH">KAOHSIUNG</option><option value="CNCAN">GUANGZHOU</option><option value="CNYTN">YANTIAN</option><option value="CNSZX">SHENZHEN</option><option value="CNLYG">LIANYUNGANG</option><option value="TWTYN">TAOYUAN</option><option value="CNFUG">FUQING, FUZHOU, 35</option><option value="TWTPE">TAIPEI</option><option value="CNXMN">XIAMEN</option><option value="CNNGB">NINGBO</option><option value="TWKEL">KEELUNG</option><option value="CNTAO">QINGDAO</option><option value="HKHKG">HONG KONG SAR, CHINA</option><option value="CNSHK">SHEKOU</option><option value="CNFOC">MAWEI FUZHOU</option></select>

当用户需要选择起始港口时,我们可以将对应的选项值传递给`payload`字典中的`pol`键,以获取相应的数据。下面是一个示例代码,其中包含了所有可选的起始港口: ```python import requests from bs4 import BeautifulSoup # 获取起始港口列表 url = 'https://www.cma-cgm.com.cn/LaraToolkit/ShipScheduleInquery/SearchList' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') pol_select = soup.find('select', {'id': 'pol'}) pol_options = pol_select.find_all('option') pol_list = [option['value'] for option in pol_options] # 用户选择起始港口 print('可选起始港口如下:') for index, pol in enumerate(pol_list): print(f'{index + 1}. {pol}') selected_index = int(input('请选择起始港口序号:')) selected_pol = pol_list[selected_index - 1] # 构造请求 url = 'https://www.cma-cgm.com.cn/LaraToolkit/ShipScheduleInquery/PostListData' payload = { 'vessel': '', 'voyage': '', 'service': 'MED', 'pol': selected_pol, 'area': '', 'etdDateFrom': '2023-06-09', 'etdDateTo': '2023-07-08', 'line': '', 'Draw': '2', 'Page': '1', 'Rows': '10', 'order': 'asc', 'sort': '' } # 发送请求 response = requests.post(url, data=payload) # 解析响应 if response.status_code == 200: data = response.json()['data'] for item in data: pol_name = item['POLName'] vessel_code = item['VesselCode'] etd_date = item['EtdDate'] si_cut_off = item['SiCutOff'] print(pol_name, vessel_code, etd_date, si_cut_off) else: print('请求失败') ``` 在上述代码中,我们首先通过 BeautifulSoup 库解析页面,获取所有可选的起始港口,并将其存储在`pol_list`列表中。然后通过用户输入选择起始港口,将其传递给`payload`字典中的`pol`键,再发送 POST 请求,获取相应的数据。

相关推荐

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.de.debook.mapper.CategoryMapper"> <resultMap id="BaseResultMap" type="com.de.debook.entity.Category"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="name" jdbcType="VARCHAR" property="name"/> </resultMap> <resultMap id="StatisticsResultMap" type="com.de.debook.entity.Statistics"> <result column="name" jdbcType="VARCHAR" property="name"/> <result column="value" jdbcType="VARCHAR" property="value"/> </resultMap> <sql id="Base_Column_List"> id, name </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from category where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from category where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.de.debook.entity.Category"> insert into category (id, name) values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="com.de.debook.entity.Category"> insert into category <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="name != null"> name, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=INTEGER}, </if> <if test="name != null"> #{name,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.de.debook.entity.Category"> update category <set> <if test="name != null"> name = #{name,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.de.debook.entity.Category"> update category set name = #{name,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> <select id="selectAll" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from category order by id asc </select> <select id="selectStatistics" resultMap="StatisticsResultMap"> SELECT t1.name as name, COUNT(*) as value FROM category t1, debook t2 WHERE t1.id = t2.category_id GROUP BY t1.id order by t1.id asc </select> </mapper>

最新推荐

recommend-type

MySQL asc、desc数据排序的实现

主要介绍了MySQL asc、desc数据排序的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

javascript打印大全(打印页面设置/打印预览代码)

代码如下: &lt;...&lt;HEAD&gt;&lt;TITLE&gt;javascript打印-打印页面设置-打印预览代码&lt;/TITLE&gt; &lt;... charset=gb2312″ /&gt; [removed] function printsetup(){ // 打印页面设置 wb.execwb(8,1);...
recommend-type

javascript 控制 html元素 显示/隐藏实现代码

1。编写js函数 [removed] function display(y){... 要显示/隐藏的html元素加上 id 属性 &lt;table&gt; &lt;tr id=”menu”&gt; &lt;td&gt;控制这个tr的显示/隐藏&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; 3,添加按钮,链接等触发 js 函数 &lt;input type=”b
recommend-type

javascript实现图片左右滚动效果【可自动滚动,有左右按钮】

本文实例讲述了javascript实现图片左右滚动效果。分享给大家供大家参考,具体如下: html代码: &lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;...meta name="description" conten
recommend-type

Javascript实现带关闭按钮的网页漂浮广告代码

代码如下: &lt;... &lt;head&gt; &lt;... charset=gb2312″&gt; &lt;title&gt;带关闭按钮的网页漂浮广告代码&lt;/title&gt;...div id=”img” style=”position: absolute;...” onmouseover=”clearInterval(interval)” ...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

从键盘输入一段英文字符串,其中包含多个字母‘h',请编写程序利用正则表达式,将英文字符串中的’h'全部改为‘H’

好的,我可以帮您解决这个问题。 您可以使用 Python 编写一个程序来实现这个功能。具体步骤如下: 1. 首先导入 re 模块,这个模块是 Python 中用于处理正则表达式的模块。 2. 然后定义一个包含英文字符串的变量,例如: text = "This is a string containing multiple h's." 3. 接下来,使用 re.sub() 方法来进行替换操作。re.sub() 方法的第一个参数是正则表达式,第二个参数是替换的字符或字符串,第三个参数是被替换的字符串。在这个例子里,我们需要将所有的小写字母 h 替换成大写字母 H,所以正则表达式可以写成
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。