任意輸入字元組成字串,對該字串中的字元按ASCII碼值升序排列後輸出,程式設計實現此功能

2021-05-02 20:11:19 字數 2705 閱讀 7511

1樓:匿名使用者

在手機知道中已有「知道君」正確的回答,電腦中為何看不見呢 ?

2樓:劉師傅的一生

public class form1

'不限制輸入的字元個數

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.

click

dim oldstr = textbox1.textdim str(oldstr.length - 1) as string

for i = 0 to oldstr.length - 1str(i) = mid(oldstr, i + 1, 1)next

'這一步很關鍵

array.sort(str)

dim newstr as string = ""

for i = 0 to oldstr.length - 1newstr += str(i)

next

textbox2.text = newstrend sub

end class

輸入任意長度的字串,將該字串中的字元按ascii碼值升序排列後輸出

3樓:匿名使用者

你是說書上讓你補全**?

那麼,你把原來的題目,完整寫上來,添空處有幾行寫清楚!

我讀了你的**,修改如下:我測試了幾個,沒有發現問題。

dim c$, s$, a as string * 1 's變數顯然應該用字元型別

dim k as integer, j as integer '這個是我加的變數宣告

c = text1

s = left(c, 1)

k = 2

doa = mid(c, k, 1)

j = 1

doif a < mid(s, j, 1) thens = left(s, j - 1) & a & right(s, len(s) - (j - 1)) '這個沒有變化

exit do 『這個是我加的end if

j = j + 1

loop until j > len(s) '這個是我修改的if j = k then s = s & ak = k + 1

loop until k > len(c)text2 = s

4樓:

程式這樣編寫,很讓人撓頭啊,含義不明的變數,兩層迴圈巢狀卻沒有說明,改寫如下:

private sub command1_click()dim c$, i%, j%, a as string * 1c = text1

for i = 1 to len(c) '氣泡排序法for j = 1 to i

if mid(c, i, 1) < mid(c, j, 1) then

a = mid(c, i, 1)

mid(c, i, 1) = mid(c, j, 1)mid(c, j, 1) = a

end if

next

next

text2 = c

end sub

輸入一個字串,將字串中的字母所有字元按ascii碼升序排列後輸出。

5樓:匿名使用者

#include

int main()

6樓:

#include "stdio.h"

#include "stdlib.h"

int cmp_char(const void *_a,const void *_b)

int main()

//這是用快速排序做的

7樓:魔尊

這就是一個排序問題嘛

c語言輸入一個字串,將字串中所有字元按ascii碼升序排列後輸出。若輸入"edcba",輸出"abcde"?

在c語言中 輸入一串字元 將該字串中所有字元按ascii碼升序後排列

8樓:匿名使用者

for(j=0;j<4;j++)

for(i=0;i<4-j;i++)

if(a[i]>a[i+1])

這樣改一下

用c語言程式設計,將字串s中的所有字元按ascii值從小到大重新排序後,將排序後的字串輸出

9樓:刀無極啊

#include "stdio.h"

#include "string.h"

int main()

printf("output:\n");

puts(s);

return 0;}

10樓:匿名使用者

**如下:

#include

#include

int main()}}

printf("%s\n", str);

return 0;

}執行結果:

11樓:匿名使用者

#include

#include

void sort(char *str,int len)謝謝!滿意請採納!

輸入字串abcdabfabc再輸入字串ab最後輸入字串99要輸出結果為abcdabf99c

1全部 輸入字串abcdabfabc 再輸入字串ab 最後輸入字串99 要輸出結果為abcdabf99c include include include void function char s,char t1,char t2,char w else break if r 0 a w w r t2 ...

VB分割字串,VB字串從指定字串分割

汗.split函式是可以指定拆分次數的.在分隔符後面指定拆分成2份就行了.樓上的竟然搞那麼複雜 debug.print split str,2 strname as string,paramarray intscores as variant dim inti,k as integerdim sub...

C語言 用字元陣列從鍵盤輸入字串,刪除字串中所有

1 遍歷字串 2 對每個字元 判斷,如果不是字母,則刪除。刪除可以通過後續字元前專移,覆蓋要刪 屬除字元的方式實現。如下 int main s j 0 printf s n s include include include int main str2 j 0 printf s str2 getch...