目前我正在尝试创建一个程序,它将从头开始自动生成一个完整的数独板,虽然相同的功能可以通过微小的改动来解决部分填充的数独板.问题是,当你在板上加载一个新的数字时,你显然必须检查这个数字是否已经存在于同一列或行中,而且也是在加载它的3x3方块中.对程序的一部分使用嵌套的switch语句,你必须根据相同的3x3方格中的数字检查数字,尽管break语句都显示在正确的位置.compliler说的是第二个case语句的第一个数字,它是嵌套switch语句的一部分:"Error:case标签值已经出现在这个开关中",即使数字没有,问题是为什么?
这是代码:
bool SudokuClass::checkPresentGrid(int &temporary, int row, int column)
{
bool indicator;
switch (row)
{
case 0 || 3 || 6: //If the number is being loaded into row 0,3 or 6
switch (column)
{
case 0 || 3 || 6: //Check all other spaces in the same 3x3 grid
if (temporary == (completeSudoku[row + 1][column + 1] || completeSudoku[row + 1][column + 2] || completeSudoku[row + 2][column + 1] || completeSudoku[row + 2][column + 2]))
{
indicator = true; …Run Code Online (Sandbox Code Playgroud) 目前我在一个应用程序中有一个函数,它接受一个浮点作为参数,并且应该对传入的值执行简单的乘法和除法.在将值传递给应用程序中的函数之前,它是对一个浮点数的类型转换为主要应用的细节处理整数的数据.不幸的是,当我将0.0的值传递给函数时,它不会生成1.0的输出(它应该从函数执行的计算中得出)但只输出值0.0并且我想知道为什么计算失败了正如我所知,程序编译时的正确输出和计算是正确的.
这是代码:
void CarPositionClass::centre(float inputPos)
{
if ((inputPos <= 0) && (inputPos >= -125))
{
membershipC = ((inputPos + 125)*(1 / 125));
}
}
Run Code Online (Sandbox Code Playgroud)
还应注意,membershipC是浮点变量,它是CarPositionClass的成员.
目前,我正在构建一个对等网络架构,并处于创建接收功能的阶段,该功能将接受来自网络上多个客户端的消息。本质上,当调用 recvfrom 函数时 - 最近向主客户端发送消息的客户端的地址被加载到名为 fromAddr 的 sockaddr_in 结构中。然后,该程序被设计为循环遍历包含客户端类的多个实例的向量(每个实例都包含表示网络上客户端的必要信息和功能),并找到其 sockaddr_in 结构与刚刚接收到的客户端实例相匹配的客户端实例信息。在程序中,评估目前看起来像这样:
void UDPClass::checkID(Message* mess, sockaddr_in fraeAddress)
{
sockaddr_in anAddr;
//Iterate through the vector of clients and find the one who sent the message
for(int i = 0; i < theClients.size(); i++)
{
anAddr = theClients[i].getAddress();
//if the address of the recieved message matches the address of the current client
if((anAddr.sin_addr == fraeAddress.sin_addr) && (anAddr.sin_port == fraeAddress.sin_port))
{
//Update local instance of the client so that its location data matches that …Run Code Online (Sandbox Code Playgroud)