我正在尝试创建一个密码生成器,生成8-16个字符之间的密码.它还必须包含一个数字和小写和大写字母,以及生成时随机放置在字符串中的一个特殊字符.
目前,我的代码有时会给我一个不符合要求的密码,例如.AOKOKKK@1(没有小写字母)此外,我还需要帮助才能使特殊符号只在密码中出现一次.我怎样才能解决这个问题?
这是我的代码:
length=$[ 8 +$[RANDOM % 16]]
char=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ! @ \# $ % ^ \&)
max=${#char[*]} …Run Code Online (Sandbox Code Playgroud) 给定一个整数数组,我需要返回一个包含原始数组中间元素的新数组.具体来说,如果原始数组的长度是奇数,则结果将具有一个元素,如果是偶数,则结果将具有两个元素.
这是我现在的代码,适用于偶数长度的数组.如何使它适用于奇数长度的数组?
public int[] makeMiddle(int[] nums) {
int[] a = new int[2];
if(nums.length>1) {
a[1]=nums[nums.length/2];
a[0]=nums[nums.length/2-1];
return a;
} else {
a[2]=nums[((nums.length+1)/2) -1];
}
return a;
}
Run Code Online (Sandbox Code Playgroud) 基本上我想要做的是获得一个启动按钮来启动在另一个类中运行的方法并作用于另一个对象.
我的听众代码:
button1a.addActionListener(new ActionListener() {
public void actionPerformed (ActionEvent event) {
// Figure out how to make this work
//sim.runCastleCrash();
}
} );
Run Code Online (Sandbox Code Playgroud)
我的其他类的代码:
public static void main(String[] args) {
CastleCrash sim;
sim = new CastleCrash();
}
Run Code Online (Sandbox Code Playgroud)
和
public void runCastleCrash() {
System.out.println("Castle Crash is beginning...");
//Other method parts here to be added
}
Run Code Online (Sandbox Code Playgroud)
我觉得这不会太难,但我错过了一块.
我将按钮的宽度指定为600dp values/dimens.xml,但是当我在Nexus 5上部署并运行它时,它会占用横向的所有可用宽度.
我的活动仅在横向模式下运行,正如我在清单文件中指定的那样.布局在layouts目录中.图像位于'drawable-xxhdpi'目录中,它们看起来很好,但我指定的所有内容都dp被放大了.
Android Studio和实际设备中的预览似乎表现为它们应该是1920时的最大宽度为600dp.为什么这样,我该如何解决?
android android-layout android-screen-support android-activity
我正在写一些类似于atoi()或的字符串转换函数strtoll().我想要包含一个我的函数版本,它接受char16_t*或char32_t*而不仅仅是char*或wchar_t*.
我的功能很好,但正如我写的那样,我意识到我不明白char16_t或char32_t是什么.我知道标准只要求它们分别是至少16或32位的整数类型,但暗示它们是UTF-16或UTF-32.
我也知道标准定义了几个函数,但它们没有包含任何*get或*put函数(就像它们wchar.h在C99中添加时那样).
所以我想知道:他们期望我用char16_t和char32_t做什么?
如何在Swift中下一个动画开始之前等待一个动画完成?我一直在乱搞if animation.animationDidStop... {},但它不会起作用.
这是我目前的一些代码:
class ViewController: UIViewController {
@IBOutlet weak var purpleRing: UIImageView!
@IBOutlet weak var beforeCountdownAnimation: UIImageView!
var imageArray = [UIImage]()
var imageArray2 = [UIImage]()
override func viewDidLoad() {
super.viewDidLoad()
for e in -17...0 {
let imageName2 = "\(e)"
imageArray2.append(UIImage(named: imageName2)!)
}
for t in 1...97 {
let imageName = "\(t)"
imageArray.append(UIImage(named: imageName)!)
}
}
func startAnimation() -> Void {
purpleRing.animationImages = imageArray
purpleRing.animationDuration = 5.0
purpleRing.startAnimating()
}
func startAnimation2() -> Void {
beforeCountdownAnimation.animationImages = imageArray2
beforeCountdownAnimation.animationDuration …Run Code Online (Sandbox Code Playgroud) 在 python 中,如果我想让某人以美元输入贷款金额,我可以编写如下代码:
# Loan amount
L = float(input("Enter the loan amount: $"))
Run Code Online (Sandbox Code Playgroud)
但如果我想要的话,比如说利率,它是一个百分比。如果我编码:
# Interest rate
I = float(input("Enter the interest rate: "))
Run Code Online (Sandbox Code Playgroud)
我怎样才能让百分号 % 在他们输入的内容后显示出来?
我正在编写一个qt基于c ++的应用程序.我有一些我希望互相排斥的按钮 - 一次只能切换一个按钮.我通常使用QButtonGroup - 它提供了一种很好的逻辑方式来管理按钮组.当一个人被按下时,先前按下的一个被压下,这正是我想要的行为.
但是,这一次,我想允许该组完全不受控制.不幸的是,这似乎是不允许的QButtonGroup:
独家:布尔
此属性保存按钮组是否为独占.
如果此属性为true,则在任何给定时间只能检查组中的一个按钮.用户可以单击任何按钮进行检查,该按钮将替换现有按钮作为组中的选中按钮.
在专用组中,用户无法通过单击取消选中当前选中的按钮; 相反,必须单击组中的另一个按钮才能为该组设置新的选中按钮.
当然,有很多方法可以解决这个问题.我想知道是否有预制替代方案QButtonGroup允许这种行为,以便1)我不是重新发明轮子和2)我可以保持在惯用之中qt,以便将来更轻松地进行项目管理.
有什么建议?
我正在尝试background-color使用JavaScript 更改按钮的属性。该脚本检查当前background-color设置为什么,然后切换它。这是JavaScript代码:
function btnColor(btn,color) {
var property=document.getElementById(btn);
if (property.style.background-color == "#f47121") {
property.style.background-color=Color;
}
else {
property.style.background-color = "#f47121";
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我在html中传递的内容:
<input type="button" id="btnHousing" value="Housing" onclick="toggleLayer('transparent1');btnColor('btnHousing','#fff200');" />
Run Code Online (Sandbox Code Playgroud)
toggleLayer是我正在使用的另一个功能,效果很好。我似乎无法弄清楚为什么它不起作用。
我需要eval在Odoo的product模块的product_demo.xml中理解以下代码中的属性:
"record id="product_product_4_product_template" model="product.template">
field name="attribute_line_ids" eval="[(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])]"/>
</record>"
Run Code Online (Sandbox Code Playgroud)
我知道attribute_line_ids这里的价值正在设定中.我也理解'ref'中的值是指XML ids,简而言之,它会返回与XML id相关的model-'product.attribute.line.
我真的不明白eval属性中的每个值的含义以及它在视图级别和数据库级别上会做出哪些更改.我已经提到了许多odoo文档,但没有一个可以提供清晰度.