随笔 - 4  文章 - 0  评论 - 0  阅读 - 38

ACM新生杯第二次周赛

第一题:

复制代码
 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     string s1, s2;
 6     int flag = 2;
 7     cin >> s1;
 8     cin >> s2;
 9     if (s1.length() != s2.length())
10     {
11         cout << 1 << endl;
12     }
13     else
14     {
15         for (int i = 0; i < s1.length(); i++)
16         {
17 
18             if (s1[i] != s2[i])
19             {
20 
21                 if (s1[i] + 32 == s2[i] || s1[i] - 32 == s2[i])
22                 {
23 
24                     flag = 3;
25                 }
26                 else
27                 {
28                     flag = 4;
29                     break;
30                 }
31             }
32         }
33         cout << flag << endl;
34     }
35 }
只要我安排的够快,烦恼就追不上我
复制代码

第二题:

复制代码
 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main() 
 5 {
 6     int n;
 7     cin  >> n;
 8     int* a  = new int[n];
 9 
10     for (int i  = 0; i  < n; i++)
11     {
12         cin  >> a[i];
13     }
14 }
View Code
复制代码

第三题:

复制代码
 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main() 
 5 {
 6     int n;
 7     cin  >> n;
 8     int* a  = new int[n];
 9 
10     for (int i  = 0; i  < n; i++)
11     {
12         cin  >> a[i];
13     }
14 }
View Code
复制代码
第四题:
复制代码
复制代码
 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     for (int i = 1; i <= 9; i++)
 7         for (int j = 0; j <= 9; j++)
 8             for (int z = 0; z <= 9; z++)
 9             {
10                 if ((i * i * i + j * j * j + z * z * z) == (i * 100 + j * 10 + z))
11                     cout << (i * 100 + j * 10 + z) << endl;
12             }
13 
14 }
View Code
复制代码
第五题:
复制代码
复制代码
 1 1 #include <iostream>
 2  2 using namespace std;
 3  3 int main()
 4  4 {
 5  5     int n;
 6  6     int m;
 7  7     cin  >> n;
 8  8     int array[1000];
 9  9     for (int i  = 0; i  < n; i++)
10 10     {
11 11         cin  >> array[i];
12 12     }
13 13     cin  >> m ;
14 14     for (int i  = 0; i  < n; )
15 15     {
16 16         if (array[i] == m)
17 17         {
18 18             cout  << i + 1;
19 19             break;
20 20         }
21 21         i++;
22 22         if (i  == n )
23 23         {
24 24             cout  << -1 << endl;
25 25             break;
26 26         }
27 27     }
28 28 }
View Code
复制代码
复制代码
复制代码
posted on   X1Cherry  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· Apache Tomcat RCE漏洞复现(CVE-2025-24813)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示