C#写一个小程序,求代码 题目要求是 输入一串字符,然后让字符串里面的内容倒过来 输出

C#写一个小程序,求代码 题目要求是 输入一串字符,然后让字符串里面的内容倒过来 输出,第1张

这是我用控制台的方式实现的,代码如下:

static void Main(string[] args)

{

//获取原始字符

Console.Write("请输入需转置字符串:")

String inputString = Console.ReadLine()

//生成字符数组

char[] charList=new char[inputString.Length]

int index = 0

//反向遍历原始字符串,获得倒序字符数组

for (int i = inputString.Length-1i >=0 i--)

{

charList[index] = inputString[i]

index++

}

//构建倒序字符串

String outputString = new string(charList)

//输出字符串转置结果

Console.Write("转置结果:")

Console.WriteLine(outputString)

Console.ReadKey()

}

#include<stdio.h>

int main()

{

float hour

printf("How many hours did you excise?\nPlease input it ^_^ :")

scanf("%f",&hour)//输入函数中“”内不能加\n;

bool a,b

a=hour>=0.5

b=hour<=1

if(a&&b)//判断时候,因为a和b本身就是Bool型,直接用自身就行

printf("Congratulations!You've had a perfect day!\n")

else if(a&&!b)

printf("You are too tired!please have a rest!\n")

else if(!a)

printf("You did not finish your excise,please keep doing it!\n")

return 0

}

补充的问题在具体点


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12167415.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-21
下一篇2023-05-21

发表评论

登录后才能评论

评论列表(0条)

    保存