Sichuan University Programming Contest 2011 Preliminary(for Non-SCUers) / A Course

返回目录

 

题目大意:  输入一些课程和对应的成绩,假设是按时间发展顺序。求重修成功(即同一课程,后一次比前面的最大成绩大的情况)次数。

 

题目类型:  模拟

 

题目分析: 虽然是水题,但是不注意细节还是很容易WA。注意点吧。

另外,既然是水题,做的时候就不要轻易放弃它,相信可能错的地方就那么几点,静下心来,逐一排查 。

 

代码 :

 

#include<cstdio> #include<cstring> using namespace std; #define MAXN 102 #define MAXM 32 struct course { int score; char name[MAXM]; } a[MAXN]; int main() { int t; scanf("%d", &t); while(t--) { int num=0; int ans = 0; int n; scanf("%d", &n); while(n--) { int find = 0; course t; scanf("%s%d", t.name, &t.score); for(int i=0; i<num; i++) if(!strcmp(t.name, a[i].name)) { if(t.score>a[i].score) { a[i].score = t.score; //更新最大 ans++; } find = 1; break; } if(!find) { //a[num].name = t.name; strcpy(a[num].name, t.name); a[num++].score = t.score; } }// Ncase printf("%d/n", ans); }//Tcase }


 官方的两个标程序:

值得学习的地方是STL map 的使用。

#include<cstdio> #include<algorithm> // #include<map> #include<iostream> #include<string> using namespace std; inline int Rint(){ int x; scanf("%d", &x); return x; } map< string, int > hash; //hash 查找表, 字符串->整型(映射) int main() { int Tcase = Rint(); while( Tcase -- ) { int n = Rint(); int ans = 0; hash.clear(); while( n -- ) { char str[100]; scanf("%s", str); int v = Rint(); if( hash.find(str) == hash.end() ) //没找到 { hash[str] = v; //注意map用法 } else { if( v > hash[str] ) { ++ ans; hash[str] = v; } } } printf("%d/n", ans); } return 0; }

#include <stdio.h> #include <map> #include <string> using namespace std; map<string, bool> sub; map<string, int> s; int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); int T, i, n, ans, score; char name[50]; scanf("%d", &T); while (T--) { scanf("%d", &n); ans=0; sub.clear(); s.clear(); for (i=0; i<n; i++) //!结构有点乱 { scanf("%s%d", name, &score); if (sub[name]) if (score>s[name]) ans++; sub[name]=true; if (score>s[name]) s[name]=score; //找不到的话,s[name] 返回0 } printf("%d/n", ans); } return 0; }

 

转载于:https://www.cnblogs.com/tclh123/archive/2011/04/08/6171776.html

<think>好的,我需要帮用户找到关于 `/etf-contest/springfox/v3/api-docs` 的API文档。首先,用户提到了Springfox,这是一个用于生成Swagger文档的库。根据引用[1],用户之前可能配置过Springfox的路径,但现在换成了smart-doc和Torna。不过用户现在还是想访问旧项目的Springfox端点。 首先,检查Springfox的配置。根据引用[1],配置中设置了`springfox.documentation.open-api.v3.path`为`/${spring.application.name}/v3/api-docs`。所以,如果项目名称是`etf-contest`,那么完整的路径应该是`/etf-contest/v3/api-docs`。但用户提供的路径是`/etf-contest/springfox/v3/api-docs`,中间多了`springfox`,这可能意味着配置中的路径被修改过,或者项目结构有变化。 接下来,用户可能需要确认项目的实际配置。如果配置中的路径变量是否正确引用了应用名称,或者是否有其他路径前缀。例如,可能需要在配置中添加`springfox`作为前缀,或者检查是否有网关路由的配置导致路径变化。 另外,用户提到源码中已经移除了Swagger,改用smart-doc,所以可能需要查看项目是否仍然保留Springfox的依赖。如果依赖被移除,那么端点可能无法访问。用户需要检查pom.xml或build.gradle文件中是否有Springfox的相关依赖,如`springfox-boot-starter`。 如果依赖存在,但端点仍然无法访问,可能需要检查Spring Security的配置,确保没有拦截该路径。或者查看应用的启动日志,确认端点是否正确注册。 最后,根据引用[1]提供的源码地址,用户可以克隆仓库查看历史提交,找到移除Swagger之前的配置,确认正确的访问路径。或者,如果项目已经切换到了smart-doc,可能需要按照新的文档生成工具的配置来访问API文档。</think>要访问项目`etf-contest`的Springfox v3 API文档端点,需按照以下步骤操作: ### 1. **确认Springfox配置** 在`application.yaml`或`application.properties`中,需确保已配置Springfox的API文档路径: ```yaml springfox: documentation: open-api: v3: path: /${spring.application.name}/v3/api-docs ``` 若项目名称是`etf-contest`,则默认生成的API文档路径为: $$ \text{http://域名:端口/etf-contest/v3/api-docs} $$ 但根据您提到的路径`/etf-contest/springfox/v3/api-docs`,需检查是否配置中添加了`springfox`前缀,或网关路由规则是否包含额外路径[^1]。 ### 2. **验证依赖和启动状态** - **依赖检查**:确保项目中包含`springfox-boot-starter`依赖(若已移除Swagger,需回退到包含Springfox的版本): ```xml <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> ``` - **日志检查**:启动项目时,观察控制台是否输出`Mapped "{v3/api-docs}"`类日志,确认端点已注册。 ### 3. **访问API文档** 直接通过以下URL访问(假设本地端口为8080): $$ \text{http://localhost:8080/etf-contest/springfox/v3/api-docs} $$ 若返回JSON格式的OpenAPI描述,则配置成功。 ### 4. **常见问题排查** - **路径冲突**:检查是否有其他路由拦截了`/v3/api-docs`路径(如Spring Security配置)。 - **历史版本配置**:根据引用[1]中的源码地址,可回退到使用Springfox的提交版本,参考历史配置。 - **替代方案**:若项目已改用`smart-doc`,需按新工具的文档规则访问接口描述[^1]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值