如何将数组1,2,3转换 “1”,“2”,“3”,请看标题,麻烦帮忙看看了,谢谢
C#还是C?C# Linq Select下在string.join转成字符串,示例如下
using System;
using System.Linq;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var arr = new[] { 1, 2, 3 };
string s = string.Join(",", arr.Select(i => "\"" + i + "\""));
Console.WriteLine(s);
Console.ReadKey();
}
}
}
数值+'0'即可
你题目的解答代码如下:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i;
int a[] = {1,2,3};
char b[3];
for (i = 0; i < 3; i++)
{
b[i] = a[i]+'0';
}
for (i = 0; i < 3; i++)
{
printf("'%c'\n",b[i]);
}
return 0;
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!