我一直在研究一些基本的编码,我正在努力找出正确的扫描方式,第一个是我的x变量,第二个是x被提升到的n.我尝试5 ^ 5并使用我当前的代码获得-287648.
#include <stdio.h>
#include <math.h>
void x_to_the_n (void)
{
int x=0;
int n =0;
long int y;
printf("Enter a integer for X and N\n");
scanf("%i\n%i\n",&x,&n);
y=pow(x,y);
printf("%i \n",y);
}
int main(void)
{
x_to_the_n ();
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我在将公共 i 作为我的代码的整数部分时遇到了麻烦。我使用 i 来保留当前行的值,以便我可以在我的程序中使用这个范围。在我的 for 循环中,它递增 i,因此它会遍历一列并搜索 v 但是当我尝试在另一组代码中使用“i”时,“i”不再具有值。我不确定全局/公共变量如何在 VBA 中工作或导致此错误的原因。
问题发生在 int Sub "yes" 和 sub "no" 代码中
Cells(i,lcol).value=" ok "
Run Code Online (Sandbox Code Playgroud)
和
Cells(i,lcol).value = " updated "
Run Code Online (Sandbox Code Playgroud)
第一组代码如下,它得到了我对“i”的价值
Public V As Integer
Public i As Integer
Private Sub Enter_Click()
Dim EmptyRow As Long
'Audit will only search Master Sheet
Worksheets("Master").Activate
'Find empty row value so we can use that for limit of search
With Sheets("Master")
EmptyRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
End With
'i needs to be …Run Code Online (Sandbox Code Playgroud)