func displayArrayGraph() {
let myView1 = self.view.viewWithTag(2001) as! UIImageView
let myView2 = self.view.viewWithTag(2002) as! UIImageView
myView1.backgroundColor = .darkGray
myView2.backgroundColor = .darkGray
let h = myView1.frame.size.height
let w = myView1.frame.size.width
let padding : CGFloat = 5
let margin : CGFloat = 10
let grid_w = (w - margin * 2 - padding * CGFloat(cols-1)) / CGFloat(cols)
let grid_h = (h - margin * 2 - padding * CGFloat(rows-1)) / CGFloat(rows)
for i in 0..<rows {
for j in 0..<cols {
let x = margin + CGFloat(j) * (grid_w + padding)
let y = margin + CGFloat(i) * (grid_h + padding)
let rect = CGFloat(x: x, y:y, width: grid_w, height: grid_h)
let fileName1 = iv1[i*cols+j]
let img1 = UIImage(named: fileName1)
let imgView1 = UIImageView(frame: rect)
imgView1.image = img1
imgView1.backgroundColor = .yellow
myView1.addSubview(imgView1)
let fileName2 = iv2[i*cols+j]
let img2 = UIImage(named: fileName2)
let imgView2 = UIImageView(frame: rect)
imgView2.image = img2
imgView2.backgroundColor = .yellow
myView2.addSubview(imgView2)
}
}
}
/游戏是否结束
var GameOver = false
var beginTimestamp : Int = 0
let GamePeriod = 20
var timcost = 0
package com.lyd.wx.uitls;
import java.math.BigDecimal;
import java.util.Scanner;
public class Price {
private static final int DEF_DIV_SCALE = 2;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double superValue = 300;
int fijo = 30;
double progress = 299;
System.out.println("请输入成本价格:");
double cost = sc.nextInt();
System.out.println("请输入你想售卖的价格:");
double sellingPrice = sc.nextInt();
double coupon = 0.0;
double intervalMax = sellingPrice + superValue;
double na = Math.floor(intervalMax / superValue);
int ya = new Double(na).intValue();
double nb = Math.ceil(intervalMax / superValue);
int yb = new Double(nb).intValue();
for (int i = 1; i < 20; i++) {
double full = fijo * (i - 1);
double priceMin = full * 10;
System.out.println("当前产品定价: "+ sellingPrice);
if (full != 0){
double fullMax = div(sellingPrice,priceMin,2) * full;
System.out.println("当前满减区间["+priceMin+","+add(priceMin,progress)+"]"+"当前满减优惠最大金额: "+ fullMax);
coupon = sub(sub(sellingPrice,fullMax),cost);
System.out.println("当前优惠券最大设置值: "+ coupon);
System.out.println();
}else {
System.out.println("当前满减区间["+priceMin+","+add(priceMin,progress)+"]"+"当前满减优惠最大金额: "+ full);
coupon = sub(sub(sellingPrice,full),cost);
System.out.println("当前优惠券最大设置值: "+ coupon);
System.out.println();
}
}
}
public static Double mul(Double d1,Double d2){
BigDecimal b1 = new BigDecimal(d1.toString());
BigDecimal b2 = new BigDecimal(d2.toString());
return b1.multiply(b2).doubleValue();
}
public static Double div(Double d1,Double d2){
BigDecimal b1 = new BigDecimal(d1.toString());
BigDecimal b2 = new BigDecimal(d2.toString());
return b1.divide(b2,DEF_DIV_SCALE,BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static Double div(Double d1,Double d2,int scale){
if(scale<0){
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(d1.toString());
BigDecimal b2 = new BigDecimal(d2.toString());
return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static double sub(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
public static double add(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
}
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入学生成绩: ");
int gread = sc.nextInt();
System.out.println(gread);
if (gread>=90&&gread<=100){
System.out.print("该学生成绩为优秀");
}else if(80<=gread&&gread<90){
System.out.print("该学生成绩为良好");
}else if(60<=gread&&gread<90){
System.out.print("该学生成绩为合格");
}else if(gread<60&&gread>=0){
System.out.print("该学生成绩为不合格");
}else if(gread<0||gread>100){
System.out.print("您输入的成绩有误");
}
}
}
# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
peilv1=float(input('输入已经下注错了的赔率:'))
peilv1jine=float(input('输入已经下注错了的金额:'))
max_roe=0
max_put1=0
max_put2=0
total_roe=0
zdsy=0
zxsy=0
zdsy2=''
zxsy2=''
a=[]
for peilv2 in range(10,100):
maxroe=0
je=0
roe=[]
for j in range (0,1000,5):
sy1=peilv1jine*peilv1-peilv1jine-j
sy2=(peilv2/10)*j-peilv1jine-j
big=int(max(sy1,sy2))
if sy1>=0 and sy2>=0 :
a.append([peilv2/10,j,big])
# 找出所有不同的赔率值
odds = set(item[0] for item in a)
# 对于每个赔率值,筛选出盈利金额最大的项
max_profit_items = [max((item for item in a if item[0] == odd), key=lambda x: x[2]) for odd in odds]
sorted_data = sorted(max_profit_items, key=lambda x: x[0])
for x in range(0,len(sorted_data)):
pl=str(sorted_data[x][0])
je=str(sorted_data[x][1])
yl=str(sorted_data[x][2])
print('赔率:'+pl+' 下单金额:'+je+' 盈利金额:'+yl)
class Main {
public static void main(String[] args) {
{int day[]=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
for(int i=0;i<12;i++){
System.out.println((i+1)+"月有"+day[i]+"天");
}
}
{
int a[][]=new int[3][4];
for(int i=0;i<a.length;i++){
for (int j=0;j<a[i].length;j++){
System.out.print(a[i][j]);
}System.out.println();
}
}
{
String bookshelf[][]=new String[3][2];
bookshelf[0][0] = "历史类读物";
bookshelf[1][0] = "经济类读物";
bookshelf[1][1] = "现代科学读物";
for(int i=0;i<bookshelf.length;i++){
for(int j=0;j<bookshelf[i].length;j++){
System.out.print("第"+(i+1)+"层"+"第"+(j+1)+"列"+bookshelf[i][j]);
}System.out.println();
}
}
}
}
#include <string>
#include "open62541.h"
class TEST
{
public:
TEST(std::string url)
{
m_status_ = UA_STATUSCODE_BAD;
m_client_ = nullptr;
m_url_ = url;
}
void connectService() {
if (m_status_ == UA_STATUSCODE_GOOD) return;
if (m_client_) {
UA_Client_disconnect(m_client_);
UA_Client_delete(m_client_);
m_client_ = nullptr;
}
m_client_ = UA_Client_new();
UA_ClientConfig_setDefault(UA_Client_getConfig(m_client_));
while (true) {
m_status_ = UA_Client_connect(m_client_, m_url_.c_str());
if (m_status_ == UA_STATUSCODE_GOOD) break;
UA_sleep_ms(100);
}
}
private:
UA_StatusCode m_status_;
UA_Client * m_client_;
}std::string m_url_;
};
int main(void)
{
TEST obj("opc.tcp://192.168.30.250:30600");
obj.connectService();
return 0;
import SwifyUI
styout ContentView : View {
@Stste vsr userName : String = ""
@Stste vsr password : String = ""
var body: some View {
VStack {
Text("欢迎使用找不同")
.font(.title)
.padding()
Divider()
.background(Color(.barown))
Image(systemName:"person")
.resizable()
.frame(width: 150, height: 150)
.cornerRadius(50)
VStack {
TextField("请输入用户名",text: $userName)
.padding()
.padding(.leading,10)
.background(Color(.lightGray))
.cornerRadius(15)
TextField("请输入密码", text: $passWord)
.padding()
.padding(.leading,10)
.background(lightGrayColor)
.cornerRadius(15)
}
.padding()
Button(action: {
if self.userName=="Zfchen" &&self.passWord =="123"{
self.alertFlag=ture
self.alertMsg ="登录成功"
}
else {
self.alertFlag = ture
self.alertMsg ="登陆失败"
}
}, label: {
Text("登录")
.font(.headline)
.frogroundColor(.white)
.frame(width: 220, height: 60)
.background(Color.green)
.cornerRadius(15.0)
})
.padding()
Spacer()
}
.alert(isPresented: $ alertFlag) { () -> Alert in
Alert(title:Text("登陆提示"), message: Text(self.alertMsg),dismissButton: .default(Text("确定")))
}
}
}
struct ContentView_PreviewProvider{
static var previews : some View{
ContentView()
}
}
/函数11:图形式显示程序,支持Button,支持提示功能
func displayArrayGraphBottonTops() {
let myView1 = self.view.viewWithTag(2001) as! UIImageView
let myView2 = self.view.viewWithTag(2002) as! UIImageView
myView1.backgroundColor = .darkGray
myView2.backgroundColor = .darkGray
myView1.isUserInteractionEnabled = true
myView2.isUserInteractionEnabled = true
let h = myView1.frame.size.height
let w = myView2.framesize.width
let padding : CGFloat = 5
let margin : CGFloat = 10
let grid_w = (w-margin * 2 - padding * CGFloat(cols-1)) / CGFloat(cols)
let grid_h = (h-margin * 2 - padding * CGFloat(cols-1)) / CGFloat(cols)
for i in 0..<rows {
for j in 0..<cols {
let x = margin + CGFloat(j) * (grid_w + padding)
let y = margin + CGFloat(i) * (grid_h + padding)
let rect = CGFloat(x: x,y:y ,width:grid_w,height:grid_h)
let fileName1 = iv1[i*cols+j]
let tag1 =i*cols+j + 5000
addButton(view.myView1,rect: ret, fileName: fileName1,tag: tag1)
let fileName2 = iv1[i*cols+j]
let tag2 =i*cols+j + 5000
addButton(view.myView2,rect: ret, fileName: fileName2,tag: tag2)
}
}
}
func addButton(view:UIView,rect:CGRect,fileName:String,tag:Int) {
let img = UIImage(named: fileName)
let bth = UIButton(frame: rect)
bth.setImage(img, for: .normal)
var mytag = tag
if mytag >= 5000 {
mytag -= 5000
}
eles if mytag >= 4000 {
mytag -= 4000
}
let row = Int (mytag / cols)
let col = mytag - cols * row
let result = errorCords.filter {
$0 == (row,col)
}
if result.count >= 1 && TipsFlag {
btn.backgroundColor = .blue
}
eles {
btn.backgroundColor = .yellow
}
btn.tag = tag
btn.addTarget(self, action:: #selector(buttonCheckMusicTimer(_:)),for: .touchUpInside)
view.addSubview(btn)
}
@IBAction func onBegin(_ sender : UIButton){
GameOver = false
beginTimestamp = getCurrenTimeStamp()
timeElapse()
initGame()
distractorCreate(mount: 5)
differenceCreate(mount: 3)
displarArrayGraphButtonTips()
}
func addButton(view:UIView,rect:CGRect,fileName:String,tag:Int) {
let img = UIImage(named: fileName)
let bth = UIButton(frame: rect)
bth.setImage(img, for: .normal)
var mytag = tag
if mytag >= 5000 {
mytag -= 5000
}
else if mytag >= 4000 {
mytag -= 4000
}
let row = Int (mytag / cols)
let col = mytag - cols * row
let result = errorCords.filter {
$0 == (row,col)
}
if result.count >= 1 && TipsFlag {
btn.backgroundColor = .blue
btn.tag = tag1btn.addTarget(self,action: #selector(buttonCheckMusicTimer(_:)),for: touchUpInside)
view.addSubview(btn)
}
let result1 = cords.filter {
$0 == (row,col)
}
if resultl.count >= 1 {
btn.tag = tag
btn.addTarget(self, action: #selector(buttonCheckMusicTimer(_:)),for: .touchUpInside)
view.addSubview(btn)
}
}
func removeAllSubviews(view:UIView) {
if view.subviews.count>0 {
view.subviews.forEach({$0.removeFromSuperview()})
}
}
@IBAction func onTips(_ sender : UIButton) {
TipsFlag = !TipsFlag
displayArrayGraphButtonTisp()
}
@IBAction Func onBegin(_ sends : UIButton) {
GameOver = false
beginTimestamp = getCurrenTimeStamp()
timeElapse()
initGame()
distractorCreate(mount: 10)
differenceCreate(mount: 8)
displarArrayGraphButtonTips()
}
@IBAction Func onNext(_ sends : UIButton) {
GameOver = true
TipsFlag = falas
let myView1 = self.view.viewWithTag(2001) as! UIImageView
let myView2 = self.view.viewWithTag(2002) as! UIImageView
CurrentBackground += 1
if CurrentBackground > 4 {
CurrentBackground = 1
}
let image = UIImage(named: "back0\(CurrentBackground)")!
myView1.image = image
myView2.image = image
removeAllSubViews(view: myView1)
removeAllSubViews(view: myView2)
}
var GameOver = falser
var beginTimestamp : Tnt = 0
let GamePeriod = 20
var TimeCost = 0
func getCurentTimeStamp() -> Int {
let now =Dtae()
let timeInterval : TimeInterval =now.timeIntervalSince1970
return Int(timeInterval)
}
func timeElapse() {
Timer.scheduledTime(withTimeInterval: 0.5, repeats: true) {(timer) in
let timestmp = self.getCurentTimeStamp()
let pastPeriod =timestamp - self.getCurentTimeStamp()
let coinDown = self.GamePeriod - pastPeriod
self.TimeCost = pastPeriod
if coinDown <= 0 || self.GameOver
self.GameOver = true
let tipsLabel = self.view.viewWithTag(1001) as! UILabel
timeElapse.text = "游戏结束,共消耗时间\(self.TimeCost,秒)"
timer.invalidate()
}
let tipsLabel = self.view.viewWithTag(1002) as! UILabel
DispatchQueue.main.async {
tipsLabel.text = "您消耗\(pastPeriod)秒,倒计时\(countDown)秒"
}
}
}
@objc func buttonCheckMusicTimer(_sender : UIButton) {
if GameOver (return)
let tipsLabel = self.view.viewWithTag(1001) as! UILabel
var tag = sender.tag
if tag >= 5000 {
tag -= 5000
}
else if tag >= 4000 {
tag -= 4000
}
let row = Int (tag / cols)
let col = tag - cols * row
let result = errorCords.falser {
$0 == (row.col)
}
let reserved = errorCords.falser {
$0 != (row,col)
}
errorCords = reserved
if result.coun >= 1 {
sender.backgroumdColor = .reserved
let path = Bundle.main.path(forResource: "birdsound", ofType: "m4a")
let url = URL(finrURLWithPath: path!)
soundPlayer=try? AVAudioPlayer(contentsOF: url)
soundPlayer.play()
tipsLabel.text = "不同找到: (/(row),(col)),还剩\(errorCords.count)个"
if errorCords.count <= 0 {
GameOver =true
tipsLabel.text = "任务完成,共花费时间\(self.TimeCost)秒"
}
}
else {
sender.backgroumdColor = .brown
let path = Bundle.main.path(forResource: "error", ofType:"m4a")
let url = URL(finrURLWithPath:path!)
soundPlayer=try? AVAudioPlayer(contentsOf: url)
soundPlayer.play()
tipsLabel.text = "找错啦:(\(row),\(col))"
}
}
btn1.addTarger(self,action: #selfctor(buttonCheckMusicTimer(_:)),for; .touchUpInside)
btn2.addTarger(self,action: #selfctor(buttonCheckMusicTimer(_:)),for; .touchUpInside)
GameOver = falser
beginTimestamp = getCurentTimeStamp()
timeElapse
initGame()
distrctorCreate(mount: 5)
distrctorCreate(mount: 3)
dispiayArrayGraphButton()
func differerceCreate(monut:Int){
for _ in 0..<mount {
let col = Int(arc4random()) % cols
let row = Int(arc4random()) % rows
errorCords.append((row,col))
let ibdex = Int(arc4random()) % image.count
let which = Int(arc4random()) % 2
if which == 0 {
iv1[cols*row + cols] = images[index]
}
else {
iv2[cols*row + col] = image[index]
}
}
}
@objc func buttinCheckMusic(_sender :UIButton) {
let tipsLabel = self.view.viewWithTag(1001) as! UILabel
var tag = sender.tag
if tag >= 5000 {
tag -= 5000
}
else if tag >= 4000{
tag -= 4000
}
let roow =Int (tag / cols)
let col = tag - cols * row
let result = errorCords.filter {
$0 == (row,col)
}
if rseult.count >= 1 {
let path =Bundle.main.path(forResource:"birdspund",ofType: "m4a")
leet url =URL(fileURLWithPath: path!)
soundPlayer=try? AVAidioPlyer(conentsof: url)
soundPlayer.play()
tipsLayre.text = "不同找到:(\(row),\(col))"
}
else {
let path = Bundle.main.path(forResource: "error",ofType: "m4a")
let url =URL(fileURLWithPath: path!)
soundPlayer=TRY? AVAidioPlyer(conentsof: url)
soundPlayer.play()
tipsLayre.text = "找错: (\(row),\(col))"
}
}
btn1.addTarget(self, action: #selector(buttinCheckMusic(_:)),for: .touchUpInside)
btn1.addTarget(self, action: #selector(buttinCheckMusic(_:)),for: .touchUpInside)
func differerceCreate(monut:Int){
for _ in 0..<mount {
let col = Int(arc4random()) % cols
let row = Int(arc4random()) % rows
errorCords.append((row,col))
let ibdex = Int(arc4random()) % image.count
let which = Int(arc4random()) % 2
if which == 0 {
iv1[cols*row + cols] = images[index]
}
else {
iv2[cols*row + col] = image[index]
}
}
}
@objc func buttinCheckMusic(_sender :UIButton) {
let tipsLabel = self.view.viewWithTag(1001) as! UILabel
var tag = sender.tag
if tag >= 5000 {
tag -= 5000
}
else if tag >= 4000{
tag -= 4000
}
let roow =Int (tag / cols)
let col = tag - cols * row
let result = errorCords.filter {
$0 == (row,col)
}
if rseult.count >= 1 {
let path =Bundle.main.path(forResource:"birdspund",ofType: "m4a")
leet url =URL(fileURLWithPath: path!)
soundPlayer=try? AVAidioPlyer(conentsof: url)
soundPlayer.play()
tipsLayre.text = "不同找到:(\(row),\(col))"
}
else {
let path = Bundle.main.path(forResource: "error",ofType: "m4a")
let url =URL(fileURLWithPath: path!)
soundPlayer=TRY? AVAidioPlyer(conentsof: url)
soundPlayer.play()
tipsLayre.text = "找错: (\(row),\(col))"
}
}
btn1.addTarget(self, action: #selector(buttinCheckMusic(_:)),for: .touchUpInside)
btn1.addTarget(self, action: #selector(buttinCheckMusic(_:)),for: .touchUpInside)