C语言数组教案
- 格式:ppt
- 大小:1.21 MB
- 文档页数:77


promotion of employment, form a reasonable and orderly pattern of income distribution, build a more fair and sustainable social security systems, medical and health system reform. The plenary, innovation of social governance, must focus on the maintenance of fundamental interests of the overwhelming majority of the people, maximize factors, enhance social development, improving social governance, the interests of national security, ensure that the people live and work, social stability and order. o improve social governance, stimulating social organization, innovative and effective system of preventing and resolving social conflicts, improving the public security system, set up the National Security Council, national security systems and national security strategy to ensure national security. Plenary session, the construction of ecological civilization, you must establish systems of ecological system, using the system to protect the ecological environment. o improve naturalresources asset property right system and use control, red line of delimitation of ecological protection, resources paid use system and ecological compensation system in ecological environment protection management system reform. Plenary session, centering on building a listening party command, can win and having a fine style of the people's army, a strong army under the new situation of the party Goals, restricting the development of national defense and army building is solved outstanding contradictions and problems, innovation and development of military theory, enhance military strategic guidance, improve the military strategy in the new period, building a modern military force system with Chinese characteristics. o deepen the adjustment of personnel system reform in the army, military policy and system reform, promote the development of military and civilian integration depth. Plenary session stressed that comprehensive reform must be to strengthen and improve theparty's leadership, give full play to the core role of the party commands the overall situation and coordinating all parties, improving the party's leading water ... Margin. Challenged the leadership of the Communist Party of China, Marxism-Leninism and Mao Zedong thought by Deng Xiao-ping's flag, replaced by three representatives and the harmonic society. The former Communist Party spirit and social cohesion point of almost all political makeover. Characteristics of socialism public ownership is shifting to private ownership, planned regulation and market regulation, the proletarian regime controlled by the elite. Of universal equality, fairness and basic principles of distribution system is socialist society, however after economic monopolized by powerful, vested interests growemployers do not have the same status, hardly seems fair social distribution. State key protection of capital interests rather than the interests of citizens, had been hits the bottom of the proletariat
1 C语言_数组
-------------------------------------------------------------------------------------------------------
数组是元素的集合,各元素数据按先后顺序存储,数据按照先后顺序连续存放在一起,各元素数据类型相同。 在使用数组前必须先进行定义再使用。一维数组只有一个下标,二维数组有两个下标,多维数组有多个下标。
一维字符数组
定义:类型说明符 数组名 [常量表达式];
例如:unsigned char Name[8];
说明定义了一个无符号字符数组Name,内部有8个元素。
第一个元素表示为Name[0],第8个元素表示为Name[7]。
例:数组连续存放表
char Name[4]; int Name[4];
数组元素 内存地址 数组元素 内存地址
Name[0] 8000 Name[0]
8000
Name[1] 8001 Name[1] 8002
Name[2] 8002 Name[2]
8004
Name[3] 8003 Name[3]
8006
说明:char 数据长度为8位,所有占用一个内存地址。Int 数据长度为16位,所有占用两个内存地址。以此类推其他类型数组占用内存地址情况。
一维数组初始化
1、在定义数组时给数组元素赋初值。
a、全部数组元素赋初值
例如: int Name[3]={1,3,5};
赋值结果:
Name[0] = 1 Name[1] = 3 Name[2] = 5
b、部分数组元素赋初值,其它数组元素自动赋以0值
例如:int Name[3]={1,3 };
赋值结果:
Name[0] = 1 Name[1] = 3 Name[2] = 0
注意:
1)数组元素的值可以是数值型、字符常量或字符串。
2)数组元素的初值必须依次放在一对大括号{ }内,各值之间用逗号隔开。
1 数组
1、将数组a中的偶数送给b数组。
void main( )
{ int a[10]={1,2,3,4,5,6,7,8,9,10};
int b[10];
k=0;
for(i=0;i<=9;i++)
{ if( )
{ ;
k++;
}
for(i=0;i
printf("%d",b[i]);
}
2、将数组a中下标值为偶数的元素从小到大排列,其他元素不变。
void main( )
{ int a[10]={1,3,9,4,5,6,2,10,7,8};
int i,j,t;
for(i=0;i<=7;i+=2)
{ for(j=i+2;j<9; )
if( )
{t=a[i];a[i]=a[j];a[j]=t;}
}
for(i=0;i<9;i++)
printf("%3d",a[i]);
}
3、下面程序的运行结果是
void main( )
{ int i,f[10];
f[0]=f[1]=1;
for(i=2;i<10;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<10;i++)
{if(i%4==0) printf("\n");
printf("%3d",f[i]);
}
}
2 4、下面程序的功能是将二维数组a中每个元素向右移一列,最右一列换到最左一列,移后的数组存到另一个二维数组b中,并按矩阵形式输出a和b,请填空。
void main( )
{ int a[2][3]={4,5,6,1,2,3},b[2][4];
C语言数组实例
Document number:NOCG-YUNOO-BUYTT-UU986-1986UT
一维
数组求平均值
main()
{floatb,s=,aver,a[6];
inti;
for(i=0;i<6;i++)
scanf("%f",&a[i]);
for(i=0;i<6;i++)
s=s+a[i];
aver=s/;
printf("%f\n",aver);
}
求数组中的最大值
main()
{floatmax,s=,a[6];
inti;
for(i=0;i<6;i++)
scanf("%f",&a[i]);
max=a[0];
for(i=1;i<6;i++)
if(max
max=a[i];
printf("最大值是:%f\n",max);
}
找出最大和最小数并调换位置
main()
{floatmax,min,s=,a[5];
inti,k=0,j=0;
for(i=0;i<5;i++)
scanf("%f",&a[i]);
max=min=a[0];
for(i=1;i<6;i++)
if(max
{max=a[i];k=i;}
if(min>a[i])
{min=a[i];j=i;}
printf("最大最小值分别在:%d,%d\n",k,j);
for(i=0;i<5;i++)
printf("%f\n",a[i]);
}
查找数组中有无此项
main()
{floata[9]={21,12,34,23,54,67,65,13,87};
ints,i;
/*for(i=0;i<9;i++)
scanf("%f",&a[i]);
printf("\n");*/
printf("请输入要查找的数:");
scanf("%d",&s);
for(i=0;i<9;i++)
if(a[i]==s)