class ArrayTest {
public void testArray(int iSize) {
for(int i=1; i<=iSize; i++) {
int[] iA = new int[i];
System.out.println("iA的尺寸為 "+iA.length);
}
}
}
public class PL_1022_HW {
public static void main(String[] args) {
// Create ArrayTest application.
ArrayTest at = new ArrayTest();
// Execute testArray
at.testArray(5);
at.testArray(10);
}
}
我只要能把上面的改寫成C和C++就能...
感謝..
2007-10-20 05:53:49 · 1 個解答 · 發問者 小烏龜 2 in 電腦與網際網路 ➔ 程式設計
#include
#include
#include
#include
using namespace std;
class tA
{
public:
void getSize(int size)
{
for(int i=1;i<=size;i++)
{
int *iA=new int[i];
cout<<"iA size ="<
delete [] iA;
}
}
};
int main(int argc, char** argv){
//=====START=====//
tA a;
a.getSize(5),a.getSize(10);
//=====END=====//
system("PAUSE");
return 0;
}
2007-10-20 17:40:45 · answer #1 · answered by Big_John-tw 7 · 0⤊ 0⤋