核心思路:利用random模組
random模組隨機生成數字,大小寫字母,迴圈次數
while迴圈+隨機生成的迴圈次數——>隨機plus++
大寫字母askii碼在65-90之間
小寫字母askll碼在97-122之間
最終效果: x個大寫字母+y個數字+z個小寫字母(x,y,z均隨機)
隨機性相較於以往單調的 小寫+數字+大寫+小寫+數字+大寫… 迴圈有所提公升
import random
print
("隨機數生成」)
time=random.
randint(1
,2)while time:
time1=random.
randint(1
,3) time2=random.
randint(1
,2) time3=random.
randint(1
,3)while time1:
a= random.
randint
(65,90
)print
("%c"%a,end="")
time1-=1
while time 2
: c= random.
randint
(0,99
)print
("%d"%c,end="")
time2-=1
while time3:
b= random.
randint
(97,122
)print
("%c"%b,end="")
time 3
-=1 time-=1
轉換大小寫字母 0330
思路分析 首先用getchar 函式獲得字元,然後判斷字元為大寫還是小寫,如果是大寫字母就轉換為小寫,如果是小寫字母就轉換為大寫 如果輸入的是數字就不輸出 定義乙個終止符,輸入終止符就退出迴圈 最後附上 define crt secure no warnings include includeint...
大小寫字母的轉化
方法1 利用tolowercase 將字串轉化為小寫,touppercase 將字串轉化為大寫。注意 轉化過程並不是對原字串s進行轉化,而是需要形成新的字串存到s中。scanner scanner new scanner system.in string s scanner.nextline sys...
大小寫字母同時排序
編寫乙個程式,將輸入字串中的字元按如下規則排序。規則1 英文本母從a到z排列,不區分大小寫。如,輸入 type 輸出 epty 規則2 同乙個英文本母的大小寫同時存在時,按照輸入順序排列。如,輸入 baba 輸出 aabb 規則3 非英文本母的其它字元保持原來的位置。如,輸入 by?e 輸出 be?...