输入任意一个大写字母,生成金字塔图形 def GoldTa(input): L = [chr(i) for i in range(65, 91)] # 大写字母A--Z idA = 65 # 从A开始 # ord()函数将字母转换为Unicode数值 idInput = ord(input) num = idInput - idA + 1 # 输入的字符个数 tempResult = "" for C in range(0, num): for C1 in range(0, C): #
要求 用户输入一个数字,按照数字打印出等腰三角形 思路 1,用户输入的数字为n代表一共有多少行 2,使用一个循环带两个for循环,第一层循环是循环行数,第二层两个平行for循环一个打印空格一个打印*号 #!/usr/bin/python #_*_ coding:utf-8 _*_ m = raw_input('请输入一个数字,我来为你打印一个等腰三角形') n = int(m) #接收输入为字符串需要先转换成整数 for i in range(1,n+1): #外层循环为行数,因为Python是
import itertools str = input('请输入一个字符串:') lst = [] for i in range(1, len(str)+1): lst1 = [''.join(x) for x in itertools.permutations(str, i)] lst += lst1 print(lst) 主要使用的itertools库
#include<stdio.h> #include<algorithm> #include<cmath> int judge(int a) { int j; for (j = 2; j <= sqrt(a); j++) { if (a%j == 0) return 1; } return 0; } int main() { int i; for (i = 1; i < 100; i++) { if (judge(i) == 0) printf("
(1)从键盘输入一个字符串(串长不大于80). (2)以十进制输出字符串中非字母字符的个数(不是a to z或 A to Z). (3)输出原字符串且令非字母字符闪烁显示. (4)找出字符串中ASCII码值最大的字符,在字符串中用红色显示. (5)字符串的输入和结果的输出都要有必要的提示,且提示独占一行. (6)要使用到子程序. data segment hintinput db "please input a string:$" hintoutput1 db "The nu
#include <stdio.h> #define sum 3+4//宏定义是原封不动的使用used for test4 #include <time.h>//used for test8~9 #include <stdlib.h>//used for test8~9 void test(){//数组输出 //int a[5]={1,2,3,4,5}; printf("array output,look,please...\n"); int a[1
不吐槽华为的服务器了,直接上正文 输入:字符串(英文字母),长度不超过128 输出:出现频率最高的字母 思路写在注释文档 /* Input a string * Output the most frequent character * * The way of thinking: * using ASCII, count the number of each character * then find out the max number(max_num) * and its according