Java 每周一题 (5)
将以下 c 代码转成 java 代码#include <stdio.h>
int main ()
{
FILE * pFile;
int a[10][4] =
{
{ 0, 0, 0, 0 },
{ 1, 1, 1, 1 },
{ 6, 2, 4, 8 },
{ 1, 3, 9, 7 },
{ 6, 4, 6, 4 },
{ 5, 5, 5, 5 },
{ 6, 6, 6, 6 },
{ 1, 7, 9, 3 },
{ 6, 8, 4, 2 },
{ 1, 9, 1, 9 },
};
int i, j;
pFile = fopen ("myfile.txt","w");
for (i = 0; i < 10; i++)
{
fprintf (pFile,"%c", '{');
for(j = 0; j < 4; j++)
{
if (j != 4-1)
fprintf (pFile, "%d%c", a[i][j], ',');
else
fprintf (pFile, "%d", a[i][j]);
}
fprintf (pFile,"%s\n", "},");
}
fclose (pFile);
return 0;
}