1。c语言:
#include
void main(){
int i;
int qianwei;
int baiwei;
int shiwei;
int gewei;
int j;
for (i=1000;i<=9999;i++){
qianwei=i/1000;
baiwei=i/100-qianwei*10;
gewei=i%10;
shiwei=(i%100-gewei)/10;
if (qianwei==baiwei&&shiwei==gewei){
for (j=10;j<=99;j++){
if (j*j==i){
printf("%d is the number! witch is the sqrare of %d。
\n",i,j);
break;
}
}
}
}
}
二。vb:在窗口建一个botton控件,一个text控件,什么都不改,双击窗体输入以下代码:
Dim i As Integer
Dim qianwei As Integer
Dim baiwei As Integer
Dim shiwei As Integer
Dim gewei As Integer
Dim j As Integer
Private Sub Command1_Click()
For i = 1000 To 9999 Step 1
qianwei = i \ 1000
baiwei = (i - qianwei * 1000) \ 100
shiwei = (i - qianwei * 1000 - baiwei * 100) \ 10
gewei = i - qianwei * 1000 - baiwei * 100 - shiwei * 10
If qianwei = baiwei And shiwei = gewei Then
For j = 10 To 99 Step 1
If j * j = i Then
Text1。
Text = i
Exit Sub
End If
Next
End If
Next
End Sub
。
全部