gpt4 book ai didi

ios - swift- get exc_bad_instruction (code=exc_i386_invop, subcode=0x0) 在 while 循环中替换数组值

转载 作者:行者123 更新时间:2023-11-29 01:02:36 29 4
gpt4 key购买 nike

我正在制作一个笔记书写应用程序。在这个应用程序中,我将线条变成贝塞尔曲线。目前,当我尝试将新值放入在 while 循环之外定义的矩阵时出现错误。当放入一个虚拟变量时,我已经单独尝试了表达式并且它在循环中工作。当我使用格式替换二维变量的值时,它在循环外工作,但是,当我在循环中同时执行这两个操作时,它不起作用。

//: Playground - noun: a place where people can play

import UIKit


var x2 = 6.0
var y2 = 5.0
var x1 = 1.0
var y1 = 1.0

var p1x = 2.0
var p1y = 3.0

var B = 6.5
var Ba = 2.2
var percentall = Ba/B

var yall = 5.0
var xall = 1.0
var A = 4.0
var C = 5.0
var Ct = 0.0
var At = 0.0
var Aall = Int(A) * 10
var Call = Int(C) * 10


var thelistx = [[Double]](count: Call, repeatedValue: [Double](count: Call, repeatedValue: 0.0 ))
var thelisty = Array(count: Aall, repeatedValue: Array(count: Call, repeatedValue: 0.0 ))


var theAt = 0
var theCt = 0


while At <= A {
var Apercent = percentall * At
var Aend = y1 + At
var yslope = (A - At) * percentall + Aend
var lefty = (yslope - Apercent) * percentall + Apercent
var righty = ( y2 - yslope) * percentall + yslope
while Ct <= C {
var Cpercent = percentall * Ct
var Cend = x2 - Ct
var xslope = (C - Ct) * percentall + Cend
var leftx = (xslope - x1) * percentall + x1
var rightx = (x2 - xslope) * percentall + xslope

thelistx [theAt] [theCt] = (rightx - leftx) * percentall + left

*********************Execution was interrupted, reason exc_bad_instruction (code=exc_i386_invop, subcode=0x0) ***************

thelisty [theAt] [theCt] = (righty - lefty) * percentall + lefty

Ct += 0.1
theCt += 1
}
At = At + 0.1
theAt += 1
}

最佳答案

控制台显示你的错误是什么:

fatal error: Index out of range

您将越界 thelistx [theAt] [theCt]

改变 while Ct < CCt < C - 1将您的调用保持在数组的范围内。

关于ios - swift- get exc_bad_instruction (code=exc_i386_invop, subcode=0x0) 在 while 循环中替换数组值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36830350/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com