(1)
(2)
(3)
C
(V
isu
al
C+
+
6.
0
4
4
(V
isu
al
C+
+
6.
0
4.2
4.3
4.5
4.4
4.1 C
(V
isu
al
C+
+
6.
0
2,C1
1,C1
4.1 C
4.1.1 C1
(V
isu
al
C+
+
6.
0
4.110
l4_1.cpp
#include"stdio.h"
main()
{ int a[10],i,min; /*aimin,a10*/
for(i=0;i<10;i++) /*a10*/
scanf("%d",&a[i]);
min=a[0]; /*a[0]min*/
for(i=1;i<10;i++) /*min,*/
if(min>a[i])
min=a[i];
printf("MIN=%d\n",min); /*min*/
}
[4.1]
4.11012,34,56,9,21,-12,34,0,-3,1a10
4.1.1 C2
(V
isu
al
C+
+
6.
0
4.22?3
l4_2.cpp
#include"stdio.h"
main()
{ int a[2][3],i,j,sum=0; /*ai,j
sum,a236*/
for(i=0;i<2;i++) for(i=0;i<2;i++) /*a6,
sum*/
for(j=0;j<3;j++)
{ scanf("%d",&a[i][j]);
sum+=a[i][j];
}
printf("Sum=%d\n",sum); /*sum*/
}
[4.2]
4.2623,12,45,-12,-34,35a6
(V
isu
al
C+
+
6.
0 4.2.2
4.2.1
4.2
4.2.3
4.1 int a[10],i,min;”aimin
4.2.1
(V
isu
al
C+
+
6.
0



4.2.2
(V
isu
al
C+
+
6.
0
[]
0nn-1
4.2.3
(V
isu
al
C+
+
6.
0
(V
isu
al
C+
+
6.
0 4.3.2
4.3.1
4.3
4.3.3
a[0][0]a[0][2]a[1][0]a[1][2]a
4.3.1
(V
isu
al
C+
+
6.
0
1
2
4.2 int a[2][3];”a2362?323a
0a6
a[0][0]a[0][1]a[0][2]
a[1][0]a[1][1]a[1][2]
for(i=0;i<2;i++) /*a6,sum*/
for(j=0;j<3;j++)
{ scanf("%d",&a[i][j]); sum+=a[i][j]; }
ij623 12 45 -12 -34 35<CR>6sumprintf("Sum=%d\n",sum);sumSum=69
4.3.2
(V
isu
al
C+
+
6.
0
01
4.2 int a[2][3];”23aa[0][0]a[0][1]a[0][2]a[1][0]a[1][1]a[1][2]a
1
2
4.3.3
(V
isu
al
C+
+
6.
0
int a[2][3]={{1,2,3},{4,5,6}};
(V
isu
al
C+
+
6.
0
4.4.2
4.4.3
4.4.1
4.4
4.4.4
4.4.5
4.4.1
(V
isu
al
C+
+
6.
0
char c[10]; /*10c*/
char c[2][10]; /*210c*/
int c[10];
int c[2][10];
char [];
char [1][2]
C
(1)char c[ ]={“How are you”};char c[ ]=“How are you”;char c[ ]={?H?,?o?,?w?,?
,?a?,?r?,?e?,,?y?,?o?,?u?,?\0?}
(2)
char c[ ][ 8]={ "white","black"};
4.4.2
(V
isu
al
C+
+
6.
0
(1),,char c[10]={?a?,?b?,?c?,?d?,?e?,?f?,?g?,?h?,?i?,?j?};
(2),char c[2][10]={{?a?,?b?,?c?},{?d?,?e?,}};
c abc\0\0\0\0\0\0\0?
de\0\0\0\0\0\0\0?
(3)
(4) char c[5]={?H?,111,119};
4.4.3
(V
isu
al
C+
+
6.
0
4.4.4
(V
isu
al
C+
+
6.
0
1scanfs,,?
” 34 5
printf()sprintf(“%s”,c); cc \0?
4.4.5
(V
isu
al
C+
+
6.
0
”,
1,gets()
2.puts()
5.strcpy()
6.strcmp()
3.strlen()
4.strcat()
char c[20];
gets(c);
How are you!<CR>
12c[0] \0?
4.4.5 1
(V
isu
al
C+
+
6.
0
1,gets()
gets()
gets()
() \0?
char c[ ]= "How\nare\nyou!";
puts(c);
How
are
you!
4.4.5 2
(V
isu
al
C+
+
6.
0
2.puts()
puts()
puts()
\0? \0? \n?
char c[20 ]= "How\nare\nyou!";
printf("%d\n",strlen(c));
12
4.4.5 3
(V
isu
al
C+
+
6.
0
3.strlen()
strlen()
strlen()
\0? \0?
char c1[30 ]= "How are you!\n";
char c1[ ]= "I am fine!";
printf("%s ",strcat(c1,c2));
How are you!
I am fine!
4.4.5 4
(V
isu
al
C+
+
6.
0
4.strcat()
strcat()
strcat(1,2)
211
strcat()112 \0?1 \0?2 \0?1
212
char c1[30 ],c2="How are you!\n";
printf("%s ",strcpy(c1,c2));
How are you!
4.4.5 5
(V
isu
al
C+
+
6.
0
5.strcpy()
strcpy()
strcyp(1,2)
211
strcpy()
112
22 \0?1
3strcpy()21strcpy(c1,c2,4);
c24c1 \0?
\0?
4.4.5 6
(V
isu
al
C+
+
6.
0
6.strcmp()
strcmp()
strcmp(11,22)
ASCII \0?
VC++ 6.0 TC 2.0
12 0 0
12 1 ASCII
12 -1 ASCII
(V
isu
al
C+
+
6.
0
2,24.6
3,34.7
1,14.5
4.5
4,44.8
#include "stdio.h"
main()
{ int i; float score[10],aver=0.0;
printf("Please input scores of 10 students:");
for(i=0;i<10;i++) /*10*/
{ scanf("%f",&score[i]);
aver+=score[i]; }
aver/=10; /*10*/
printf("The average score is:%.2f\n",aver);
printf("They are:");
for(i=0;i<10;i++) /**/
if(score[i]>aver)
printf("%6.2f",score[i]);}
4.5 14.5
(V
isu
al
C+
+
6.
0
4.510l4_5.cpp
4.5 14.5
(V
isu
al
C+
+
6.
0
10
4.5 24.6
(V
isu
al
C+
+
6.
0
#include "stdio.h"
main()
{ int i,j,t,a[10];
printf("Please input 10 numbers:\n");
for(i=0;i<10;i++) /*10a*/
scanf("%d",&a[i]);
for(i=0;i<9;i++) /*a10*/
for(j=0;j<9-i;j++)
if(a[j]>a[j+1]) /**/
{ t=a[j]; a[j]=a[j+1]; a[j+1]=t; }
printf("The sorted numbers are:");
for(i=0;i<10;i++) /*a10*/
printf("%d ",a[i]);
printf("\n");
}
4.5 24.6
(V
isu
al
C+
+
6.
0
4.5 24.6
(V
isu
al
C+
+
6.
0
89 67 45 87 32 1 0 45 2 3<CR>
10
4.5 34.7
(V
isu
al
C+
+
6.
0
#include "stdio.h"
main()
{ int i,k,j,t,a[10];
printf("Please input 10 numbers:\n");
for(i=0;i<10;i++) scanf("%d",&a[i]); /*10a*/
for(i=0;i<9;i++) /*a10*/
{ k=i;
for(j=i+1;j<10;j++)
if(a[k]>a[j]) k=j;
t=a[k]; a[k]=a[i]; a[i]=t; /**/
}
printf("The sorted numbers are:");
for(i=0;i<10;i++) printf("%d ",a[i]); /*a10*/
printf("\n");
}
4.5 34.7
(V
isu
al
C+
+
6.
0
5switch—casel4_8.cpp
4.5 44.8
(V
isu
al
C+
+
6.
0
4.8
1
2
3
#include "stdio.h"
#define N 4 /*N4*/
#define M 5 /*M5*/
main()
{ int select; int score[N][M],i,j,aver,num;
while (1) /**/
{ printf(" !\n\n");/**/
printf("* * * * * * * * * * * * * * * * * * * * * *\n");
printf("*,*\n");
printf("* 1,*\n");
printf("* 2,*\n");
printf("* 3,*\n");
printf("* 4,*\n");
printf("* 5,*\n");
INPUT:
4.5 44.81
(V
isu
al
C+
+
6.
0
4.5 44.82
(V
isu
al
C+
+
6.
0
INPUT:
printf("* * * * * * * * * * * * * * * * * * * * * *\n");
printf(" 1—5,");
scanf("%d",&select);
if(select==5) /**/
break;
if(select>=6||select<=0) /**/
{ printf("* * * 1-5* * *\n");
goto INPUT;
}
aver=0;
4.5 44.83
(V
isu
al
C+
+
6.
0
switch(select)
{ case 1,/**/
printf("\n");
scanf("%d",&num);
for(i=0;i<N;i++)
if(num==score[i][0])
for(j=1;j<M;j++)
{ printf("%d%d\n",j,score[i][j]);
aver+=score[i][j];
}
printf("%d%d\n",num,aver/(M-1));
break;
4.5 44.84
(V
isu
al
C+
+
6.
0
case 2,/**/
printf("(1-%d)\n",M-1);
scanf("%d",&j);
for(i=0;i<N;i++)
{ printf("%d%d\n",i+1,score[i][j]);
aver+=score[i][j];
}
printf("%d%d\n",j,aver/N);
break;
case 3,/**/
printf("\n");
scanf("%d%d",&num,&j);
for(i=0;i<N;i++)
if(num==score[i][0])
printf("%d%d%d\n",num,j,score[i][j]);
break;
case 4,/**/
printf("%d%d(\n",N,M-1);
for(i=0;i<N;i++)
for(j=0;j<M;j++)
scanf("%d",&score[i][j]);
break;
default:break; } } }
4.5 44.85
(V
isu
al
C+
+
6.
0
4.5 44.8
(V
isu
al
C+
+
6.
0
1—
5