是否可以仅反转单词中的字母?
例如,如果我有这个词 $word = "word,!";
我需要结果 $result = "drow,!";
我试过使用strrev但它也反转了标点符号.
好的,我想从控制台输入一个整数,并检查数字是否为素数.我挖出了一个代码,然后根据我的需要对其进行了转换,但计算不正确.
using System;
class PrimeNumber
{
static void Main()
{
Console.Write("Type a number: ");
string line = Console.ReadLine(); // Read string from console
int value;
if (int.TryParse(line, out value)) // Try to parse the string as an integer
{
int x = 0;
if (value == 1) Console.WriteLine("not prime");
if (value == 2) Console.WriteLine("prime");
for (int i = 3; i < value*value; i+=2)
{
if (value % 2 == 0) x++; break;
if (value % i == 0) x++; break; …Run Code Online (Sandbox Code Playgroud)