首页 > 试题广场 >

while

[编程题]while
  • 热度指数:1167 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
\hspace{15pt}小歪找到了一个由五个字符构成的字符串,它一次可以选择任意一个字符,将其修改为另一个字符,他想要知道,将这个字符串修改为 \texttt{ 需要的最少操作次数。

输入描述:
\hspace{15pt}输入一个长度为 5,由小写字母构成的字符串 s


输出描述:
\hspace{15pt}输出一个整数,表示将字符串 s 修改为 \texttt{ 需要的最少操作次数。
示例1

输入

while

输出

0
示例2

输入

wlill

输出

2
头像 Leavery
发表于 2025-04-28 14:32:08
补完题 发一下个人题解 A 模拟 #include <iostream> using namespace std; int main() { string s, t = "while"; cin>>s; int cnt = 0; for (int i=0; 展开全文
头像 可爱抱抱呀😥
发表于 2025-04-28 22:33:39
D~F Java题解,代码已去除冗余~~~ D 数组4.0 容易观察到,连续至少两种数字的集合,点与点之间可以相互到达,因为可以利用相邻的数字作为桥;连续一种数字,则需要组内数字连边至少成树;;而以上的组之间需要至少连边成树,时间复杂度(Tnlogn) import java.util.*; pub 展开全文
头像 shanzhi7
发表于 2025-05-01 04:04:29
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; vector a; vector pre; unordered_map<int, int> me; int root(int x) 展开全文
头像 shanzhi7
发表于 2025-05-01 04:06:01
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; vector<int> a; v 展开全文
头像 牛客732405425号
发表于 2025-12-14 16:22:07
n=input() b=['w','h','i','l','e'] count=0 for i in range(5): if n[i] not in b[i]: count+=1 print(count)
头像 涂图被offer砸中
发表于 2026-01-16 01:17:32
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner sc = 展开全文
头像 _苏格拉底_
发表于 2025-11-25 20:59:05
#include<iostream> using namespace std; int main(){ string s; cin >> s; int times=0; if(s[0]!='w')times++; if(s[1]!='h 展开全文
头像 霜山雨迟
发表于 2026-01-29 14:37:38
#include <iostream> #include <string> using namespace std; int main() { string s1; cin >> s1; string s2 = "whil 展开全文
头像 While1729
发表于 2025-11-20 22:51:32
#include <stdio.h> #include<string.h> int main() { char target[]="while"; char input[6]; scanf("%5s",input 展开全文