c语言程序设计课件数组,第五章 数组_《C语言程序设计(Visual C++ 6.0环境)》电子教案_ppt_大学课件预览_高等教育资讯网...
1
2
3
0
[ ],
(1)
( )
int a[6];
a[0]0
1
4
5
a[1]
a[2]
a[3]
a[4]
a[5]
2
3
a
=*
sizeof()
5.1
4
[ ]
int i=15;
int data[i]; (?)
int a[10];
printf(“%d”,a); (?)
for(j=0;j<10;j++)
printf(“%d\t”,a[j]); (?)
int data[5];
data[5]=10; //C
5
(
int a[5]={1,2,3,4,5};
a[0]=1; a[1]=2; a[2]=3; a[3]=4; a[4]=5;
static0
int a[5]={6,2,3};
a[0]=6; a[1]=2;a[2]=3; a[3]=0; a[4]=0;
int a[3]={6,2,3,5,1}; (?)
static int a[5];
a[0]=0; a[1]=0; a[2]=0; a[3]=0; a[4]=0;
int a[]={1,2,3,4,5,6};
6
1a[0]>a[1]
n-1
n——
2n-1
n-1
3n-1
10
7
38
49
65
76
13
27
30
97
38
49
65
13
27
30
76
38
49
13
27
30
65
38
13
27
30
49
13
27
30
38
13
27
30
49
38
65
97
76
13
27
30
n=8
38
49
76
9713
97
97
27
30
97
13
76
76
76
27
30
13
6527
6530
65
13
13
49
4930
4927
3827
3830
38
13
27
10
8
1n-1n
—
2n-2n-1
—
3n-1
10
9
[ 49 38 65 97 76 13 27 ]
k
j
i=1 13 49
13 [38 65 97 76 49 27 ]i=2 27 38
13 27 [65 97 76 49 38 ]
13 27 38 [97 76 49 65 ]
13 27 38 49 [76 97 65 ]
13 27 38 49 65 [97 76 ]
13 27 38 49 65 76 [97 ]
k
kk
k
j j j j j
j j j j j
10
10
[][]
:
int a[3][4];
float b[2][5];
int c[2][3][4];
int a[3,4]; (?)
=*
int a[3][2]
a[0][1]
a[1][0]
a[1][1]
a[2][0]
a[2][1]
0
1
4
5
2
3
a[0][0]
a[0][0] a[0][1]
a[1][0] a[1][1]
a[2][0] a[2][1]
int c[2][3][4]
0
1
2
34
5
6
7……….
..
20
21
22
23
c[0][0][0]
c[0][0][1]
c[0][0][2]
c[0][0][3]
c[0][1][0]
c[0][1][1]
c[0][1][2]
c[0][1][3]
c[0][2][0]
c[0][2][1]
c[0][2][2]
c[0][2][3]
c[1][0][0]
c[1][0][1]
c[1][0][2]
c[1][0][3]
c[1][1][0]
c[1][1][1]
c[1][1][2]
c[1][1][3]
c[1][2][0]
c[1][2][1]
c[1][2][2]
c[1][2][3]
5.2
11
int a[3][4];
2016
17
2018
19
2020
21
2022
23
2008
9
2010
11
2012
13
2014
15
2000
1
2002
3
2004
5
20006
7a[0][0] a[0][1] a[0][2] a[0][3]
a[1][0] a[1][1] a[1][2] a[1][3]
a[2][0] a[2][1] a[2][2] a[2][3]
a[i]4
a3
a[0]
a[1]
a[2]
0
1
4
5
2
3
a[0][1]
a[0][2]
a[0][3]
a[1][0]
a[1][1]
a[0][0]
a[1][3]
a[2][0]
a[2][1]
a[2][2]
a[2][3]
a[1][2]6
7
10
11
8
9
a[0]
a[1]
a[2]
12
[ ][ ]
int a[2][3]={{1,2,3},{4,5,6}};
a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 2 3 4 5 6
int a[2][3]={{1,2},{4}};
a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 2 0 4 0 0
int a[][3]={{1},{4,5}};
a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 0 0 4 5 0
int a[2][3]={1,2,3,4,5,6};
a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 2 3 4 5 6
int a[2][3]={1,2,4};
a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 2 4 0 0 0
int a[][3]={1,2,3,4,5};
a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 2 3 4 5 0
13
a= 1 2 34 5 6 b= 1 42 5
3 6
#include
main()
{ int a[2][3]={{1,2,3},{4,5,6}};
int b[3][2],i,j;
printf("array a:\n");
for(i=0;i<=1;i++)
{ for(j=0;j<=2;j++)
{ printf("%5d",a[i][j]);
b[j][i]=a[i][j];
}
printf("\n");
}
printf("array b:\n");
for(i=0;i<=2;i++)
{ for(j=0;j<=1;j++)
printf("%5d",b[i][j]);
printf("\n");
}
}
14
max=a[0][0]
for i=0 to 2
for j=0 to 3
a[i][j]>max
max=a[i][j]
row=i
colum=j
maxrow,colum
#include
main()
{ int a[3][4]={{1,2,3,4},
{9,8,7,6},
{-10,10,-5,2}};
int i,j,row=0,colum=0,max;
max=a[0][0];
for(i=0;i<=2;i++)
for(j=0;j<=3;j++)
if(a[i][j]>max)
{ max=a[i][j];
row=i;
colum=j;
}
printf("max=%d,row=%d,\
colum=%d\n",max,row,colum);
}
15
char c[10],ch[3][4];
char ch[5]={?H?,?e?,?l?,?l?,?o?};
ch[0]
H e l l o
ch[1] ch[2] ch[3] ch[4]
!
char ch[5]={?H?,?e?,?l?,?l?,?o?};
ch[0]
H e l l o
ch[1] ch[2] ch[3] ch[4]
char ch[5]={?B?,?o?,?y?};
ch[0]
B o y \0 \0
ch[1] ch[2] ch[3] ch[4]
r [ =“Boy”;
[
\ \
[ [ [ [
char ch[6]={“H llo”};
char ch[6]=“Hello”;
char ch[]=“Hello”;
ch[0]
H e l l o
ch[1] ch[2] ch[3] ch[4]
\0
ch[5]
5.3
16
char diamond[][5]={{'.','.','*'},{'.','*','.','*'},
{'*','.','.','.','*'},{'.','*','.','*'},{'.','.','*'}};
.,* \0 \0
,*,* \0
*,,,*
,*,* \0
.,* \0 \0
diamond[0]
diamond[1]
diamond[2]
diamond[3]
diamond[4]
char fruit[][7]={“Apple”,”Orange”,
”Grape”,”Pear”,”Peach”};
fruit[0]
fruit[1]
fruit[2]
fruit[3]
fruit[4]
A p p l e \0 \0
O r a n g e \0
G r a p e \0 \0
P e a r \0 \0 \0
P e a c h \0 \0
17
\0?
hello”5 6 5
ASCII
18
I/O %c
I/O %s
main()
{ char str[5];
int i;
for(i=0;i<5;i++)
scanf(“%c”,&str[i]);
for(i=0;i<5;i++)
printf(“%c”,str[i]);
}
main()
{ char str[5];
scanf(“%s”,str);
printf(“%s”,str);
}
,&
<
\0?
,
\0?
19
main()
{
int i;
char a[5];
scanf("%s",a);
for(i=0;i<5;i++)
printf("%d,",a[i]);
}
1 hel,
2 hell,
3 hello,%s
h e l \0
h e l l \0
h e l l o
20
H o w \0
a r e \0
y o u? \0
#include
main()
{ char a[15],b[5],c[5];
scanf("%s%s%s",a,b,c);
printf("a=%s\nb=%s\nc=%s\n",a,b,c);
scanf("%s",a);
printf("a=%s\n",a);
}
How are you?
a=How
b=are
c=you?
How are you?
a=How
How are you?
21
string.h
puts
puts()
\0?
gets
gets()
\0?
#include
main( )
{ char string[80];
printf(“Input a string:”);
gets(string);
puts(string);
}
,How are you?
,How are you?
22
strcat
strcat(1,2)
21
1
1
,\0?;,1 \0?,
\0?
strcpy
strcpy(1,2)
21
1
1
\0?
char str1[20],str2[20];str1={“Hello!”}; (?)
str2=str1; (?)
1
23
strcmp
strcmp(1,2)
ASCII
\0?
inta,1< 2
b,1> 2
c,1== 2
==”,strcmp
strlen
strlen()
\0?
strlen(s)
1char s[10]={?A?,?\0?,?B?,?C?,?\0?,?D?};
2char s[ ]=“\t\v\\\0will\n”;
3char s[ ]=“\x69\082\n”; 1 3 1
2
24
#include
#include
main()
{ char str1[] =,Hello!",str2[] =,How are you?”,str[20];
int len1,len2,len3;
len1=strlen(str1); len2=strlen(str2);
if(strcmp(str1,str2)>0)
{ strcpy(str,str1); strcat(str,str2); }
else if (strcmp(str1,str2)<0)
{ strcpy(str,str2); strcat(str,str1); }
else strcpy(str,str1);
len3=strlen(str);
puts(str);
printf(”Len1=%d,Len2=%d,Len3=%d\n”,len1,len2,len3);
} How are you?Hello!
Len1=6,Len2=12,Len3=18
Ch6_23.c
strcmpstrlen
25
string
i=0 num=0 word=0
((c=string[i])!=?\0?)
c=
word=0 word=1
num=num+1
i=i+1
num
word==0
#include
main()
{ char string[81];
int i,num=0,word=0;
char c;
gets(string);
for(i=0;(c=string[i])!='\0';i++)
if(c==' ') word=0;
else if(word==0)
{ word=1; num++; }
printf("There are %d words \
in the line\n",num);
}
26
=
word=0,num
(word==0),,
word=1,num1
(word==1),,num
0
1
1
1
0
1
0
1
2
1
1
2
1
0
2
0
1
3
1
0
3
0
1
4
1
1
4
1
1
4
1
1
4
I?am?a?boy.
word
word
num
I a m a b o y,
27
92 85 68 75 54 88 98 45 61 79
92
85
68
54
88
98
45
75
61
79
a[0]
a[1]
a[2]
a[3]
a[4]
a[5]
a[6]
a[7]
a[8]
a[9]
a
#include
main()
{ int k,a[10];
for(k=0;k<10;k++)
scanf(“%d”,&a[k]);
for(k=0;k<10;k++)
sum+=a[k];
printf(“Average is %d\n”,sum/10);
}
92 85 68 75
54 88 98 45
61 79 81 40
c语言程序设计课件数组,第五章 数组_《C语言程序设计(Visual C++ 6.0环境)》电子教案_ppt_大学课件预览_高等教育资讯网...相关推荐
- matlab 有一函数 _写一程序_输入自变量的值_输出函数值.,第2讲 MATLAB入门1_数学建模_ppt_大学课件预览_高等教育资讯网...
数学建模与数学实验 MATLAB入门数学建模及其基于 MATLAB的实现辽宁工程技术大学理学院应用数学系 MATLAB作为线性系统的一种分析和仿真工具,是理工科大学生应该掌握的技术工具,它作为一种编程 ...
- 信息学奥赛一本通(C++版)第一部分 C++语言 第五章 数组
第五章 数组 第一节 一维数组 T1102 : 与指定数字相同的数的个数 时间限制: 1000 ms 内存限制: 65536 KB [题目描述] 输出一个整数序列中与指定数字相同的数的个数. [输 ...
- 《程序设计技术》第五章例程
<程序设计技术>例程 <程序设计技术>第一章 C语言与程序设计(例程) <程序设计技术>第二章 C语言基础知识(例程) <程序设计技术>第三章 程序控制 ...
- C语言控制结构程序设计,第3讲 C语言程序的基本控制结构_C语言程序设计(上)_pps_大学课件预览_高等教育资讯网...
Page 1 C语言程序设计 清华大学 郑莉 安颖莲第三讲 C语言程序的基本控制结构参考书,计算机程序设计基础,第三章 ,C程序设计,第四章.第五章 Page 2 C语言程序设计 清华大学 郑莉 安颖 ...
- 【JAVA SE】第五章 数组、多维数组和Arrays类
第五章 数组.多维数组和Arrays类 文章目录 第五章 数组.多维数组和Arrays类 一.数组 1.概述 2.声明数组变量 3.创建数组 4.For-Each 循环 二.多维数组 1.概述 2.多 ...
- R语言实战笔记--第十五章 处理缺失数据
R语言实战笔记–第十五章 处理缺失数据 标签(空格分隔): R语言 处理缺失数据 VIM mice 缺失值(NA),是导致我们计算错误的一大来源,处理缺失数据在实际的应用中有着较为重要的作用. 基本方 ...
- QT编程从入门到精通之三十四:“第五章:Qt GUI应用程序设计”之“5.5 Qt Creator使用技巧”
目录 第五章:Qt GUI应用程序设计 5.5 Qt Creator使用技巧 第五章:Qt GUI应用程序设计 在"Qt 程序创建基础"上,本章将继续深入地介绍Qt Creator ...
- 西安电子科技大学java答案_第3章 数 组_西安电子科技大学:JAVA语言_ppt_大学课件预览_高等教育资讯网...
第 3章 数组 第 3章 数 组 3.1 一维数组 3.2 二维数组 第 3章 数组 3.1 一 维 数 组 一维数组是最简单的数组, 在 Java中, 数组是作为 数组类的一个实例来处理的, 故可以 ...
- c语言第五章作业,《C语言程序设计》第五章作业.doc
<C语言程序设计>第五章作业 窗体顶端 <C语言程序设计>第5章作业 布置日期:2012-3-15?????截止日期:2012-3-22 一. 单选题 (每小题6分,共102分 ...
最新文章
- 论文浅尝 - ICML2020 | 通过关系图上的贝叶斯元学习进行少样本关系提取
- 编译程序和解释程序有哪些区别?
- 使用Navicat计划任务备份数据库
- 数据3分钟丨Snowflake获“2021 DBMS”;OceanBase社区版3.1.2正式发布
- 古代婚姻和现代社会矛盾了。导致大量大龄女性未婚
- Codeforces Round #224 (Div. 2): C. Arithmetic Progression(模拟)
- 一道经典JS题(关于this)
- javascript事件之:谈谈自定义事件
- web容器 Spring容器 SpringMVC容器 的关系
- 【转载】Linux GCC常用命令
- java dbutil_DBUtil java工具类
- vue下载文件流图片
- 优点三维逆向建模——消除实景三维应用后顾之忧
- 使用Android Studio导入源码
- 从小程序到小程序云开发
- 模拟网易云的H5音乐播放器
- 托福经验分享:20天从93分考到105分
- 读取/data/data/下文件或者数据库
- Appium安装与初步使用
- 现代社会,各行各业的竞争越来越激烈
热门文章
- 一种新的高级抖动分离解析方法
- 2021年大数据HBase(五):HBase的相关操作JavaAPI方式
- java处理中文字符_Java中文字符处理的四大迷题
- Android 属性动画(Property Animation) ObjectAnimator的介绍
- Java NIO(New I/O)的三个属性position、limit、capacity
- (循环练习题) 五只猴子分桃子
- C# 视频多人脸识别的实现过程
- DAY74-Django框架(五)
- 2022-2028年中国电子签名行业深度调研及投资前景预测报告
- Ubuntu VSCode OpenCV 环境配置