100
环中最长子串
#include <iostream>
using namespace std;
int main()
{
string str;
cin >> str;
int n,i = 0;
while (str[i] != '\0')
{
if(str[i] == 'o')
{
n ++;
}
i ++;
}
printf("%d\n", n % 2 ? i - 1 : i);
return 0;
}
螺旋数字矩阵
#include <iostream>
#include <vector>
using namespace std;
//int res[100][100];
int main()
{
int nums,n;
cin >> nums >> n;
int m = (nums - 1) / n + 1;
vector<vector<string>> res(n, vector<string>(m, "*"));
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
for(int x = 0, y = 0, d = 0, k = 1; k <= nums; k ++)
{
res[x][y] = to_string(k);
int a = x + dx[d], b = y + dy[d];//a,b表示下一个位置
if(a < 0 || a >= n || b < 0 || b >= m || res[a][b] != "*")
{
d = (d + 1) % 4;
a = x + dx[d], b = y + dy[d];
}
x = a, y = b;
}
for(int i = 0; i < n; i ++)
{
for(int j = 0; j < m; j++) cout << res[i][j] << ' ';
cout << endl;
}
return 0;
}
最富裕的小家庭
找座位
#include <bits/stdc++.h>
using namespace std;
int main() {
int res = 0;
string str;
cin >> str;
for (int i = 0; i < str.length(); i++) {
if (str[i] == '0')
{ //空位是第一位或左边有空位
bool left = i == 0 || str[i - 1] == '0';
// 空位是最后一位或右边有空位
bool right = i == str.length() - 1 || str[i + 1] == '0';
// 两者都满足
if (left && right) {
res++;
str[i] = '1'; // 坐一个人
i++;
}
}
}
cout << res << endl;
return 0;
}
密码输入检测
#include <bits/stdc++.h>
using namespace std;
int dx, xx, sz, n;
bool check(string &str)
{
n = str.size();
if(n < 8) return false;
for(auto & ch : str)
{
if(ch >= 'a' && ch <= 'z') xx++;
else if(ch >= 'A' && ch <= 'Z') dx++;
else if(ch >= '0' && ch <= '9') sz++;
}
if(xx >= 1 && dx >= 1 && sz >= 1 && sz + xx + dx < n) return true;
return false;
}
int main()
{
string str,res;
cin >> str;
for(auto &ch : str)
{
if(ch == '<' ) {if(res.size()) res.pop_back();}
else res.push_back(ch);
}
string flag = "false";
if(check(res)) flag = "true";
cout << res << ',' << flag << endl;
return 0;
}
分配土地
智能成绩表
#include <bits/stdc++.h>
using namespace std;
int idx;
struct stu
{
string name;
vector<int> scores;
};
stu stus[1010];
bool compare(stu& a, stu& b)
{
if(a.scores[idx] != b.scores[idx])
return a.scores[idx] > b.scores[idx];
return a.name < b.name;
}
int main()
{
string course_names[11];
int n,m;
cin >> n >> m;
for(int i = 0; i < m; i ++) cin >> course_names[i];
for(int i = 0; i < n; i ++)
{
cin >> stus[i].name;
int sum = 0;
for(int j = 0; j < m; j ++)
{
int score;
cin >> score;
stus[i].scores.push_back(score);
sum += score;
}
stus[i].scores.push_back(sum);
}
string key;
cin >> key;
idx = m;
for(int i = 0; i < m; i ++)
{
if(course_names[i] == key)
{
idx = i;
break;
}
}
sort(stus , stus + n, compare);
for(int i = 0; i < n; i ++)
{
cout << stus[i].name;
if(i == n) cout << endl;
else cout << " ";
}
return 0;
}
转盘寿司
开源项目热度榜单
提取字符串中的最长合法简单数学表达式
机器人搬砖
内存冷热标记
爱吃蟠桃的孙悟空
虚拟理财游戏
游戏分组
围棋的气
万能字符单词拼写、掌握的单词个数
小明找位置
分割均衡字符串
小华地图寻宝
数的分解
执行任务赚积分
计算二又搜索树的高度
API集群负载统计
剩余银饰的重量
最多购买宝石数目
小明的幸运数
悄悄话
CPU算力分配
分披萨
机场航班调度程序
攀登者1
生成哈夫曼树
密码解密
来自异国的客人
求幸存数之和
会议室占用时间
石头剪刀布游戏
手机App防沉迷系统
小朋友来自多少小区
精准核酸检测
多段线数据压缩
测试用例执行计划
堆内存申请
灰度图存储
火星文计算2
200
电脑病毒感染
小朋友分组最少调整次数
又树计算
分月饼
最长连续手牌
5G网络建设
攀登者2
园区参观路径
部门人力分配
结队编程
数据单元的变化替换
高效货运
找数字
中文分词模拟器
符号运算
根据IP查找城市
文件缓存系统
员工派遣
跳格子3
贪吃的猴子
项目排期
亲子游戏
可以处理的最大任务数
推荐多样性
两个字符串间的最短路径问题
跳马
路口最短时间问题
字符串拼接
Wonderland
伐木工
抢7游戏
寻找最优的路测线路
篮球游戏
矩阵匹配
最小矩阵宽度
启动多任务排序
贪心歌手
反射计数
模拟目录管理功能
特殊的加密算法
田忌赛马
最长子字符串的长度(二)