Java编程语言,书上的作业题
packagecom.cainiaoqi;
importjava.util.Scanner;
publicclassTest3{
*@paramargs
publicstaticvoidmain(String[]args){
//TODOAuto-generatedmethodstub
intn;
Scannerin=newScanner(System.in);
intarray[][];
n=in.nextInt();
array=newint[n][n];
for(inti=0;i
for(intj=0;j
if(i==j)
array[i][j]=1;
array[i][j]=0;
for(inti=0;i
for(intj=0;j
System.out.print(array[i][j]+"\t");
System.out.println();
c语言编程作业
#include
voidinsert(inta[],int*len,intx)
inti,j;
for(i=0;i<*len;i++)
if(x
for(j=*len-1;j>=i;j--)
a[j+1]=a[j];
a[i]=x;
(*len)++;
break;
a[*len]=x;
(*len)++;
voiddel(inta[],int*len,intx)
inti,j;
for(i=0;i<*len;i++)
if(x==a[i])
for(j=i;j<*len-1;j++)
a[j]=a[j+1];
(*len)--;
intmain()
inta[10]={1,2,3,4,5};
intlen=5;
inti,x;
for(i=0;i
printf("%3d",a[i]);
printf("\n");
scanf("%d",&x);
if(x>0)
insert(a,&len,x);
if(x<0)
del(a,&len,-x);
for(i=0;i
printf("%3d",a[i]);
printf("\n");
return0;
#include
voidcp(char*s,intm,char*p)
inti=0;
while(*s)
if(i>=m)
*p++=*s;
*p=\0;
intmain()
chara[20],b[20];
intm;
scanf("%s",a);
scanf("%d",&m);
cp(a,m,b);
printf("%s\n",b);
return0;
#include
voidprint(chars)
if(s==Z)
printf("YZA\n");
printf("%c%c%c",s-1,s,s+1);
intmain()
charc;
scanf("%c",&c);
print(c);
return0;
本回答由提问者推荐