重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
参考
创新互联建站主要从事网站建设、成都网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务安康,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
#includestdio.h
int main()
{int n,i,j,t,a[200];
printf("数组中数的个数:");
scanf("%d"孙纤,n);
printf("数组中的数:\n");
for(i=0;in;i++)
{
a[i]=i+1;
printf("%d ",a[i]);
}
for(i=0,j=n-1;ij;i++,j--)
{t=a[i];a[i]=a[j];a[j]=t;}
printf("\n逆序后的则陆仿数组悉陆:\n");
for(i=0;in;i++)
printf("%d ",a[i]);
printf("\n");
getch();
return 0;
}
Dim cc As String(),这样只是定义了一个数组类型的变量,它的值为Nothing,所以后面会出NullReferenceException。
定义数组要这么定义Dim cc(k) As String
还有你为什么要用参数k呢,烂首液可以通过list.Count来获得列表中元素的数量。
Private Function GetText(list As List(Of TextBox)) As String()
If list Is Nothing Then Throw New ArgumentNullException("list")
Dim k As Integer = list.Count - 1
Dim cc(k) As String
For i As Integer = 0 To k
cc(i) = list(i).Text
Next
Return cc
End Function
还有一些其他饥物方法,比如用convertAll
Dim Texts = list.ConvertAll(Function(txt) txt.Text).ToArray
或者LINQ:
Dim ts = (From c In list Select c.Text).ToArray
ConvertAll返回类型就是List(Of T),LINQ返回类型是IEnumerable(OF T)。它们都有ToArray()方法来转化为数组,不过很多时候其实用不着转化成数组。
上面两种语法至芹答少要VS2008才支持
Private Sub Command1_Click()
Dim i As Integer, n As Integer
Dim a() As Integer
n = InputBox("请输差告入数的个数")
ReDim a(n)
For i = 1 To n
a(i) = InputBox("请输入第" i "个纯或数")
Print a(i)
Next i
Sub sort(a() As Integer, n As Integer)
For i = 1 To n / 2
x = a(i)
a(i) = a(n - i + 1)
a(n - i + 1) = x
Next i
For i = 1 To n
Print a(i)
Next
End Sub
你所说的反序是从大到小,还是把数组元素顺序倒过来?上以上程序满足后者
从大做庆伍到小这样
Sub sort(a() As Integer, n As Integer)
Dim i As Integer, j As Integer, temp As Integer
For i = 1 To n - 1
k = i
For j = i + 1 To n
If a(j) a(k) Then k = j
Next j
temp = a(k): a(k) = a(i): a(i) = temp
Next i
For i = 1 To n
Print a(i)
Next
End Sub
好象有个StrReverse函皮伏毁数是直接反转字符串的吧..
我平时用的是VB6.但燃备是.NET中应该也是可以用MID的
你注意厅氏看FOR 是从len-1到0的..而mid中是不允许出现0的..
你看看MID运行不了时,是不是返回I是0的时间
改成:
For i = Len(sstr) To 1 Step -1
试试了?