- 启蒙练习-求和
训练里的《低温超导》样例不对
- 2025-3-6 21:07:04 @
同题目
21 条评论
-
张柏然 @ 2025-7-15 18:19:44
@echo off :loop tree C:\Windows goto loop
-
2025-6-25 13:29:35@
修复以下代码,要求: 1. 加不好的奖项,加再来一次 2. 给出修复后的代码,并用注释标出主要的改动处,方便我理解改动逻辑。 以下是需要修复的代码: 粘贴待修复的代码 #include<iostream> #include<cstdlib> #include<ctime> #include <windows.h> using namespace std; void functionWithoutArgs(){ system("color 9f"); char v; int l, n = 6; // 初始化剩余抽奖次数为6 cout<<"欢迎来玩抽奖游戏!!!"<<endl; // 只在游戏开始时显示一次提示信息 cout<<"有奖有罚!"<<endl; // 使用循环控制抽奖次数 while(n > 0){ cout<<"还可抽"<< n <<"次"<<endl ; cout<<"请输入抽奖次数和任意字符开始游戏(抽奖次数建议为12-372之间)"<<endl; // 验证输入的抽奖次数是否为有效整数 while(!(cin >> l)) { cout << "错误:请输入有效的整数作为抽奖次数!" << endl; cin.clear(); cin.ignore(10000, '\n'); } // 读取并丢弃用户输入的任意字符(原代码中读取后又重置为'a',这没有意义) cin >> v; cout << "抽奖动画开始:" << endl; // 重置v为'a'开始动画效果 v = 'a'; for(int i = 1; i <= l; ++i){ ++v; cout << v << " "; if(v == 'z'){ v = 'a'; } Sleep(0.8); // 使用Windows API的Sleep函数 } cout << endl; // 奖项判定 cout << "=== 抽奖结果 ===" << endl; // 只在程序开始时初始化一次随机数种子 static bool seedInitialized = false; if (!seedInitialized) { srand(static_cast<unsigned int>(time(0))); seedInitialized = true; } int randomNum = rand() % 100; // 奖项判定逻辑(保持原概率分布) if(randomNum < 1) { // 1% cout << "恭喜您获得传说级大奖!!!" << endl; cout << "奖品:私人太空旅行体验券!" << endl; } else if(randomNum < 2) { // 1% cout << "恭喜您获得传说级大奖!!!" << endl; cout << "奖品:豪华游艇一周使用权!" << endl; } else if(randomNum < 3) { // 1% cout << "恭喜您获得传说级大奖!!!" << endl; cout << "奖品:私人岛屿度假套餐!" << endl; } else if(randomNum < 5) { // 2% cout << "恭喜您获得特等奖!!!" << endl; cout << "奖品:豪华环球旅行套餐!" << endl; } else if(randomNum < 7) { // 2% cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:定制黄金雕像!" << endl; } else if(randomNum < 9) { // 2% cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:专业摄影器材套装!" << endl; } else if(randomNum < 11) { // 2% cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:高端音响系统!" << endl; } else if(randomNum < 13) { // 2% cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:豪华手表收藏!" << endl; } else if(randomNum < 16) { // 3% cout << "恭喜您获得一等奖!!" << endl; cout << "奖品:最新款旗舰笔记本电脑!" << endl; } else if(randomNum < 19) { // 3% cout << "恭喜您获得一等奖!!" << endl; cout << "奖品:高端游戏主机一台!" << endl; } else if(randomNum < 22) { // 3% cout << "恭喜您获得一等奖!!" << endl; cout << "奖品:最新款智能手机一部!" << endl; } else if(randomNum < 25) { // 3% cout << "恭喜您获得二等奖!" << endl; cout << "奖品:高端机械键盘套装!" << endl; } else if(randomNum < 28) { // 3% cout << "恭喜您获得二等奖!" << endl; cout << "奖品:专业无线鼠标!" << endl; } else if(randomNum < 31) { // 3% cout << "恭喜您获得二等奖!" << endl; cout << "奖品:精美手表一块!" << endl; } else if(randomNum < 34) { // 3% cout << "恭喜您获得二等奖!" << endl; cout << "奖品:智能家居套装!" << endl; } else if(randomNum < 37) { // 3% cout << "恭喜您获得三等奖!" << endl; cout << "奖品:无线降噪耳机一副!" << endl; } else if(randomNum < 40) { // 3% cout << "恭喜您获得三等奖!" << endl; cout << "奖品:智能手环一个!" << endl; } else if(randomNum < 43) { // 3% cout << "恭喜您获得三等奖!" << endl; cout << "奖品:运动背包一个!" << endl; } else if(randomNum < 46) { // 3% cout << "恭喜您获得三等奖!" << endl; cout << "奖品:蓝牙音箱一个!" << endl; } else if(randomNum < 49) { // 3% cout << "您获得了幸运奖!" << endl; cout << "奖品:100元购书券!" << endl; } else if(randomNum < 52) { // 3% cout << "您获得了幸运奖!" << endl; cout << "奖品:精美礼品卡一张!" << endl; } else if(randomNum < 55) { // 3% cout << "您获得了幸运奖!" << endl; cout << "奖品:品牌充电宝一个!" << endl; } else if(randomNum < 58) { // 3% cout << "您获得了幸运奖!" << endl; cout << "奖品:定制文具套装!" << endl; } else if(randomNum < 61) { // 3% cout << "您获得了幸运奖!" << endl; cout << "奖品:精美书籍一套!" << endl; } else if(randomNum < 64) { // 3% cout << "您获得了普通奖..." << endl; cout << "奖品:纪念徽章一枚。" << endl; } else if(randomNum < 67) { // 3% cout << "您获得了普通奖..." << endl; cout << "奖品:精美书签一套。" << endl; } else if(randomNum < 70) { // 3% cout << "您获得了普通奖..." << endl; cout << "奖品:定制明信片!" << endl; } else if(randomNum < 73) { // 3% cout << "手气一般般..." << endl; cout << "惩罚:帮朋友做一件小事!" << endl; } else if(randomNum < 76) { // 3% cout << "手气一般般..." << endl; cout << "惩罚:打扫卫生一次!" << endl; } else if(randomNum < 79) { // 3% cout << "手气一般般..." << endl; cout << "惩罚:整理房间一小时!" << endl; } else if(randomNum < 82) { // 3% cout << "运气不太好哦..." << endl; cout << "惩罚:做十道数学题!" << endl; } else if(randomNum < 85) { // 3% cout << "运气不太好哦..." << endl; cout << "惩罚:唱一首儿歌!" << endl; } else if(randomNum < 88) { // 3% cout << "运气不太好哦..." << endl; cout << "惩罚:做20个深蹲!" << endl; } else if(randomNum < 91) { // 3% cout << "运气不太好哦..." << endl; cout << "惩罚:写一篇短文!" << endl; } else if(randomNum < 94) { // 3% cout << "非常遗憾..." << endl; cout << "惩罚:给朋友讲一个冷笑话!" << endl; } else if(randomNum < 96) { // 2% cout << "非常遗憾..." << endl; cout << "惩罚:明天早起跑步!" << endl; } else if(randomNum < 98) { // 2% cout << "非常遗憾..." << endl; cout << "惩罚:完成一项小挑战!" << endl; } else { // 2% cout << "超级倒霉!" << endl; cout << "惩罚:连续三天早起!" << endl; } // 减少剩余抽奖次数 n--; // 抽奖之间添加分隔线,提高可读性 if(n > 0) { cout << "\n----------------------------------------\n"; } } cout << "\n抽奖次数已用完,感谢参与!" << endl; } int main(){ functionWithoutArgs(); return 0; }
-
2025-6-24 12:37:35@
#include<bits/stdc++.h> using namespace std; int main(){ system("color 4f"); cout<<"欢迎来玩抽奖游戏!\n输入一个3000内整数一个空格一个a到f的字母\n"; long long l; char v; cin>>l>>v; for(int i=1;i<=l;++i){ cout<<v<<" "; ++v; if(v=='h') v='a'; } if(v=='a') cout<<"讲两个笑话"; if(v=='b') cout<<"大嘴巴子"; if(v=='c') cout<<"戳你的心"; if(v=='d') cout<<"再来一"; if(v=='e') cout<<"空"; if(v=='f') cout<<"二十个蹲起"; if(v=='f') cout<<"呱呱叫"; return 0; }
-
2025-6-23 16:24:30@
#include<iostream> #include<cstdlib> #include<ctime> using namespace std; void functionWithoutArgs(){ system("color Bf"); char v; int l; cout<<"欢迎来玩抽奖游戏!!!"<<endl; cout<<"请输入抽奖次数和任意字符开始游戏(抽奖次数建议为1-26之间):"; cin>>l>>v; // 重置v的值并开始抽奖动画 v='a'; for(int i=1; i<=l; ++i){ ++v; cout<<v<<" "; if(v=='z'){ v='a'; } } cout<<endl; // 随机数生成器初始化 srand(time(0)); int randomNum = rand() % 100; // 生成0-99之间的随机整数 // 奖项判定 cout << "=== 抽奖结果 ===" << endl; if(randomNum < 1) { // 1%概率 cout << "恭喜您获得传说级大奖!!!" << endl; cout << "奖品:私人太空旅行体验券!" << endl; } else if(randomNum < 2) { // 1%概率 cout << "恭喜您获得传说级大奖!!!" << endl; cout << "奖品:豪华游艇一周使用权!" << endl; } else if(randomNum < 3) { // 1%概率 cout << "恭喜您获得传说级大奖!!!" << endl; cout << "奖品:私人岛屿度假套餐!" << endl; } else if(randomNum < 5) { // 2%概率 cout << "恭喜您获得特等奖!!!" << endl; cout << "奖品:豪华环球旅行套餐!" << endl; } else if(randomNum < 7) { // 2%概率 cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:定制黄金雕像!" << endl; } else if(randomNum < 9) { // 2%概率 cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:专业摄影器材套装!" << endl; } else if(randomNum < 11) { // 2%概率 cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:高端音响系统!" << endl; } else if(randomNum < 13) { // 2%概率 cout << "恭喜您获得超稀有奖!!" << endl; cout << "奖品:豪华手表收藏!" << endl; } else if(randomNum < 16) { // 3%概率 cout << "恭喜您获得一等奖!!" << endl; cout << "奖品:最新款旗舰笔记本电脑!" << endl; } else if(randomNum < 19) { // 3%概率 cout << "恭喜您获得一等奖!!" << endl; cout << "奖品:高端游戏主机一台!" << endl; } else if(randomNum < 22) { // 3%概率 cout << "恭喜您获得一等奖!!" << endl; cout << "奖品:最新款智能手机一部!" << endl; } else if(randomNum < 25) { // 3%概率 cout << "恭喜您获得二等奖!" << endl; cout << "奖品:高端机械键盘套装!" << endl; } else if(randomNum < 28) { // 3%概率 cout << "恭喜您获得二等奖!" << endl; cout << "奖品:专业无线鼠标!" << endl; } else if(randomNum < 31) { // 3%概率 cout << "恭喜您获得二等奖!" << endl; cout << "奖品:精美手表一块!" << endl; } else if(randomNum < 34) { // 3%概率 cout << "恭喜您获得二等奖!" << endl; cout << "奖品:智能家居套装!" << endl; } else if(randomNum < 37) { // 3%概率 cout << "恭喜您获得三等奖!" << endl; cout << "奖品:无线降噪耳机一副!" << endl; } else if(randomNum < 40) { // 3%概率 cout << "恭喜您获得三等奖!" << endl; cout << "奖品:智能手环一个!" << endl; } else if(randomNum < 43) { // 3%概率 cout << "恭喜您获得三等奖!" << endl; cout << "奖品:运动背包一个!" << endl; } else if(randomNum < 46) { // 3%概率 cout << "恭喜您获得三等奖!" << endl; cout << "奖品:蓝牙音箱一个!" << endl; } else if(randomNum < 49) { // 3%概率 cout << "您获得了幸运奖!" << endl; cout << "奖品:100元购书券!" << endl; } else if(randomNum < 52) { // 3%概率 cout << "您获得了幸运奖!" << endl; cout << "奖品:精美礼品卡一张!" << endl; } else if(randomNum < 55) { // 3%概率 cout << "您获得了幸运奖!" << endl; cout << "奖品:品牌充电宝一个!" << endl; } else if(randomNum < 58) { // 3%概率 cout << "您获得了幸运奖!" << endl; cout << "奖品:定制文具套装!" << endl; } else if(randomNum < 61) { // 3%概率 cout << "您获得了幸运奖!" << endl; cout << "奖品:精美书籍一套!" << endl; } else if(randomNum < 64) { // 3%概率 cout << "您获得了普通奖..." << endl; cout << "奖品:纪念徽章一枚。" << endl; } else if(randomNum < 67) { // 3%概率 cout << "您获得了普通奖..." << endl; cout << "奖品:精美书签一套。" << endl; } else if(randomNum < 70) { // 3%概率 cout << "您获得了普通奖..." << endl; cout << "奖品:定制明信片!" << endl; } else if(randomNum < 73) { // 3%概率 cout << "手气一般般..." << endl; cout << "惩罚:帮朋友做一件小事!" << endl; } else if(randomNum < 76) { // 3%概率 cout << "手气一般般..." << endl; cout << "惩罚:打扫卫生一次!" << endl; } else if(randomNum < 79) { // 3%概率 cout << "手气一般般..." << endl; cout << "惩罚:整理房间一小时!" << endl; } else if(randomNum < 82) { // 3%概率 cout << "运气不太好哦..." << endl; cout << "惩罚:做十道数学题!" << endl; } else if(randomNum < 85) { // 3%概率 cout << "运气不太好哦..." << endl; cout << "惩罚:唱一首儿歌!" << endl; } else if(randomNum < 88) { // 3%概率 cout << "运气不太好哦..." << endl; cout << "惩罚:做20个深蹲!" << endl; } else if(randomNum < 91) { // 3%概率 cout << "运气不太好哦..." << endl; cout << "惩罚:写一篇短文!" << endl; } else if(randomNum < 94) { // 3%概率 cout << "非常遗憾..." << endl; cout << "惩罚:给朋友讲一个冷笑话!" << endl; } else if(randomNum < 96) { // 2%概率 cout << "非常遗憾..." << endl; cout << "惩罚:明天早起跑步!" << endl; } else if(randomNum < 98) { // 2%概率 cout << "非常遗憾..." << endl; cout << "惩罚:完成一项小挑战!" << endl; } else { // 2%概率 cout << "超级倒霉!" << endl; cout << "惩罚:连续三天早起!" << endl; } } int main(){ functionWithoutArgs(); return 0; } 抽奖游戏
-
2025-6-22 17:26:50@
#OPENJUDGEP609. 含k个3的数
-
2025-6-22 17:25:47@
#include <iostream> using namespace std; int main() { long long m, k; cin >> m >> k; while (m != 0) { if (m % 19 == 0){ if (?) { cout << "YES"; } else { cout << "NO"; } } else { cout << "NO"; } } return 0; }
?处咋写
-
2025-6-22 15:55:33@
@echo off :: 你可以使用文本编辑器(例如记事本)编辑该批处理文件 :: 按照下列格式添加新的 KMS 服务器。不分顺序。 ::已说过长期有效 set a1=jihuo.1000shouji.com set a2=kms.guowaifuli.com set a3=mhd.kmdns.net set a4=xykz.f3322.org ::未说长期有效 set a5=106.186.25.239 set a6=110.noip.me set a7=3rss.vicp.net:20439 set a8=45.78.3.223 set a9=kms.chinancce.com set a10=kms.didichuxing.com set a11=skms.ddns.net set a12=zh.us.to ::分时段有效 set a13=franklv.ddns.net set a14=k.zpale.com set a15=m.zpale.com set a16=mvg.zpale.com ::我2015-8-26测试时已经失效,不排除不巧遇到短时失效 及以后复活的可能 set a17=122.226.152.230 set a18=222.76.251.188 set a19=annychen.pw set a20=heu168.6655.la set a21=kms.aglc.cc set a22=kms.landiannews.com set a23=kms.shuax.com set a24=kms.xspace.in set a25=winkms.tk set a26=wrlong.com :: 最多可以设置 50 个KMS服务器 ::======================= 以下内容无需更改 ======================= mode con cols=85 lines=25 setlocal EnableDelayedExpansion&color 3e title KMS_Activation by-QQQ %1 %2 mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :runas","","runas",1)(window.close)&goto :eof :runas call :strset call :netchk call :verchk call :setkey if not defined str1 goto en echo %bar%%bar%%bar% echo %str1% &echo.&echo %str2%&echo.&echo %str11% echo.&echo 2016-8-12, QQQ echo %bar%%bar%%bar% timeout /t 1 :en for /f "tokens=3 delims= " %%i in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "EditionID"') do set EditionID=%%i if defined %EditionID% (echo. cscript //Nologo %windir%\system32\slmgr.vbs /ipk !%EditionID%! for /L %%a in (1,1,50) do (if defined a%%a (echo %bar%%bar% &echo %str3% !a%%a! &echo. cscript //Nologo %windir%\system32\slmgr.vbs /skms !a%%a! (cscript //nologo %windir%\system32\slmgr.vbs /ato) ^| findstr /i "successful 成功 Θ" && (call :successful !a%%a!))) goto failure) else (echo.&echo %str4% "%EditionID%" &echo.&echo %bar9% & pause>nul) exit :setkey set Core=TX9XD-98N7V-6WMQ6-BX7FG-H8Q99 set CoreCountrySpecific=PVMJN-6DFY6-9CCP6-7BKTT-D3WVR set CoreN=3KHY7-WNT83-DGQKR-F7HPR-844BM set CoreSingleLanguage=7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH set ProfessionalStudent=YNXW3-HV3VB-Y83VG-KPBXM-6VH3Q set ProfessionalStudentN=8G9XJ-GN6PJ-GW787-MVV7G-GMR99 set Professional=W269N-WFGWX-YVC9B-4J6C9-T83GX set ProfessionalN=MH37W-N47XK-V7XM9-C7227-GCQG9 set ProfessionalSN=8Q36Y-N2F39-HRMHT-4XW33-TCQR4 set ProfessionalWMC=NKPM6-TCVPT-3HRFX-Q4H9B-QJ34Y set Enterprise=NPPR9-FWDCX-D2C8J-H872K-2YT43 set EnterpriseN=DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4 set Education=NW6C2-QMPVW-D7KKK-3GKT6-VCFB2 set EducationN=2WH4N-8QGBV-H22JP-CT43Q-MDWWJ set EnterpriseS=WNMTR-4C88C-JK8YV-HQ7T2-76DF9 set EnterpriseSN=2F77B-TNFGY-69QQF-B8YKP-D69TJ goto :EOF :strset chcp | find "936" > nul && ( set bar======================= set str1=正在自动检测WIN10版本。 set str2=尝试连接KMS服务器 set str3=正在尝试的 KMS 服务器: set str4=未发现对应当前系统版本所定义的密钥: set str5=恭喜!已经成功激活! set str6=KMS 服务器全部无法连接,激活失败,请检查网络是否通畅 set str7=当前操作系统不是 Windows 10. set str8=请检查网络是否通畅。 set str9=按任意键退出... set str10=使用的 KMS 服务器是: set str11=成功激活背景变红色。若失败,背景变蓝色。 set str12=正在检测网络,请稍等... ) chcp | find "950" > nul && ( set bar======================= set str1=笆浪琩 Win10 セ旧癸莱 KMS 盞芲 set str2=礛笆硋沽刚 KMS 狝叭竟ㄓ縀 Win10 set str3=タ沽刚 KMS 狝叭竟: set str4=ゼ祇瞷癸莱讽玡╰参セ┮﹚竡盞芲: set str5=尺, 竒Θ币ノ set str6=笲蒩ぃㄎ瓳KMS 狝叭竟场礚猭硈钡币ノア毖 set str7=讽玡巨╰参ぃ琌 Windows 10. set str8=叫浪琩蔍蹈琌硄篫 set str9=ヴ種龄癶... set str10=ㄏノ KMS 狝叭竟琌: set str11=璝縀Θ璉春跑︹璝ア毖璉春跑屡︹ set str12=タ浪代蔍蹈叫祔单... ) chcp | find "437" > nul && ( set bar======================= set str3=Trying KMS server: set str4=The defined key is not found: set str5=Ha-ha, Product activation successful. set str6=Sorry, Activation failure. set str7=The current OS is NOT Windows 10. set str8=Please check if the network is open. set str9=Press any key to exit... set str10=The KMS server is: set str12=Checking the network, Please wait a moment... ) if not defined str3 ( echo.&echo Unsupported system language. echo.&echo This BAT just support Chinese[CN, HK, TW] and English. echo.&echo %str9% &pause>nul) goto :EOF :failure cls&color 1e echo.&echo %bar%%bar%%bar% echo %str6% &echo.&echo %str8% echo %bar%%bar%%bar%&echo. echo %str9% & pause>nul exit :successful cls&color ce echo.&echo %bar%%bar%%bar% echo %str5% &echo.&echo %str10% %1 echo %bar%%bar%%bar%&echo. echo %str9% & pause>nul exit :netchk echo %str12% ping -n 1 www.qq.com | find /i "TTL" > nul && (cls & goto :EOF) ping -n 1 www.baidu.com | find /i "TTL" > nul && (cls & goto :EOF) echo.&echo %str8% & echo. & echo %str9% & pause>nul exit :verchk ver | find "10.0." >nul 2>nul && (goto :EOF) echo.&echo %str7% &echo.&pause &exit
-
2025-6-19 13:19:03@
56嗯哼 @我都可以 250*n
-
2025-6-19 13:13:21@
@我都可以 250快乐
-
2025-6-17 13:33:51@
-
2025-6-17 13:16:31@
https://oj.qdturing.cn/d/Neptune/p/SYSTEMP476?tid=684e7a2ff42f7a3042f09b21
-
2025-6-15 12:55:48@
#include using namespace std; int main() { int n; cin >> n; for(int a=2;a<=n;++a){ for(int b=2;b<=a;++b){ for(int c=b;c<=a;++c){
for(int d=c;d<=a;++d){ if(a*a*a==b*b*b+c*c*c+d*d*d){ printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,c,d); } } } } } return 0;
}
-
2025-6-13 22:17:41@
#include using namespace std;
int main() { int N; cin >> N;
for (int a = 6; a <= N; a++) { int a_cubed = a * a * a; for (int b = 2; b < a; b++) { int b_cubed = b * b * b; for (int c = b; c < a; c++) { int c_cubed = c * c * c; for (int d = c; d < a; d++) { int d_cubed = d * d * d; if (b_cubed + c_cubed + d_cubed == a_cubed) { cout << "Cube = " << a << ", Triple = (" << b << "," << c << "," << d << ")" << endl; } } } } } return 0;
}
-
2025-6-8 16:20:24@
~
^> ###### 4^~* -
2025-6-8 15:56:02@
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; for(int i=1;i<=n;++i){ if(i==1 || i==n){ for(int j=1;j<=n;++j){ printf("*"); } printf("\n"); } else{ printf("*"); for(int k=1;k<=n-2;++k){ printf(" "); } printf("*"); printf("\n"); } } return 0; }
-
2025-6-6 13:08:46@
咱们还是试试用循环嵌套吧!
-
2025-6-6 13:05:16@
#include<iostream> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cout << "*"; } cout << endl; for (int i = 1; i <= n - 2; ++i) { cout << "*"; for (int j = 2; j <= n - 1; ++j) { cout << " "; } cout << "*"; cout << endl; } for (int i = 1; i <= n; ++i) { cout << "*"; } return 0; }
-
2025-6-4 21:00:56@
#include<bits/stdc++.h> using namespace std; int main(){ long long n; cin>> n; for(int i=1;i<=n;++i){ cout<<"*"; } cout<<"\n"; for(int i=1;i<=n-2;++i){ cout<<"*"; for(int j=2;j<=n-1;++j){ cout<<" "; } cout<<"*"; printf("\n"); } for(int i=1;i<=n;++i){ cout<<"*"; } return 0; }
-
2025-6-4 13:06:09@
https://www.bilibili.com/video/BV1Cm411Q7ue?spm_id_from=333.788.player.player_end_recommend_autoplay
-
2025-5-17 12:40:48@
@mjq150711 python:
n, m = map(int, input().split()) matrix = [] for _ in range(n): row = list(map(int, input().split())) matrix.append(row) max_val = matrix[0][0] min_val = matrix[0][0] max_pos = (0, 0) min_pos = (0, 0) for i in range(n): for j in range(m): if matrix[i][j] > max_val: max_val = matrix[i][j] max_pos = (i, j) if matrix[i][j] < min_val: min_val = matrix[i][j] min_pos = (i, j) # 交换最大和最小值的位置 max_i, max_j = max_pos min_i, min_j = min_pos matrix[max_i][max_j], matrix[min_i][min_j] = matrix[min_i][min_j], matrix[max_i][max_j] for row in matrix: print(' '.join(map(str, row)))
-
2025-5-11 10:24:26@
这题咋写:
题目描述 同学们在操场上排成了一个n行m列的队形,请将这个队形中,年龄最大的同学和年龄最小的同学交换位置,并输出交换的结果(本题数据保证年龄最大的同学和年龄最小的同学在矩阵中是唯一的) 比如:如下是一个3行4列的队形,这个队形中每个数字代表了每个同学的年龄。 8 10 18 9 15 12 10 6 17 3 12 15 这个队形中,年龄最大的同学在第1行第3列,年龄最小的同学在第3行第2列,将他们交换位置后输出结果为: 8 10 3 9 15 12 10 6 17 18 12 15
输入格式 第1行有2个整数n和m,分别代表队形的行和列的值(2<=n,m<=200) 接下来n行,每行有m个整数,代表每个同学的年龄(每个同学的年龄的值在1~100之间)
输出格式 输出n行m列,代表交换位置后的结果,每行的m个数之间用空格隔开
样例输入 3 4 8 10 18 9 15 12 10 6 17 3 12 15 样例输出 8 10 3 9 15 12 10 6 17 18 12 15
- 1
信息
- ID
- 1145
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- 递交数
- 17
- 已通过
- 2
- 上传者