C程序设计第三版谭浩强著
- 格式:pptx
- 大小:9.86 MB
- 文档页数:43


谭浩强c++程序设计课后答案
娄警卫
2 / 75
第一章
1.5题
#include
using namespace std;
int main()
{
cout<<"This"<<"is";
cout<<"a"<<"C++";
cout<<"program.";
return 0;
1.6题
#include
using namespace std;
int main()
{
int a,b,c;
a=10;
b=23;
c=a+b;
cout<<"a+b=";
cout<
cout<
return 0;
}
1.7七题
#include
using namespace std;
int main()
{
int a,b,c;
int f(int x,int y,int z);
cin>>a>>b>>c;
c=f(a,b,c);
cout<
return 0;
}
int f(int x,int y,int z)
{
int m;
if (x
else m=y;
if (z
}
1.8题
#include
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
c=a+b;
cout<<"a+b="<
return 0;
}
1.9题
#include
using namespace std;
int main()
{
int a,b,c;
int add(int x,int y);
cin>>a>>b;
c=add(a,b);
cout<<"a+b="<
return 0;
}
int add(int x,int y)
{int z;
z=x+y;
return(z);
}
3 / 75
第二章
2.3题
#include
using namespace std;
1
谭浩强C语言程序设计习题参考答案
第一章
1.6
main()
{int a,b,c,max;
printf("input three numbers:\n");
scanf("%d,%d,%d",&a,&b,&c);
max=a;
if(max
if(max
printf("max=%d",max);
}
第二章
2.3
(1)(10)10=(12)8=(a)16
(2)(32)10=(40)8=(20)16
(3)(75)10=(113)8=(4b)16
(4)(-617)10=(176627)8=(fd97)16
(5)(-111)10=(177621)8=(ff91)16
(6)(2483)10=(4663)8=(963)16
(7)(-28654)10=(110022)8=(9012)16
(8)(21003)10=(51013)8=(520b)16
2.6
aabb (8)cc (8)abc
(7)AN
2.7
main()
{char c1='C',c2='h',c3='i',c4='n',c5='a';
c1+=4, c2+=4, c3+=4, c4+=4, c5+=4;
printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5);
}
2.8
main()
{int c1,c2;
c1=97;c2=98;
printf("%c %c",c1,c2);
}
2.9
(1)=2.5
(2)=3.5
2.10
9,11,9,10 2 2.12
(1)24 (2)10 (3)60 (4)0 (5)0 (6)0
第三章
3.4
main()
{int a,b,c;
long int u,n;
float x,y,z;
char c1,c2;
a=3;b=4;c=5;
x=1.2;y=2.4;z=-3.6;
完美WORD格式
专业整理 知识分享 第一章
1.5题
#include
using namespace std;
int main()
{
cout<<"This"<<"is";
cout<<"a"<<"C++";
cout<<"program.";
return 0;
1.6题
#include
using namespace std;
int main()
{
int a,b,c;
a=10;
b=23;
c=a+b;
cout<<"a+b=";
cout<
cout<
return 0;
}
1.7七题
#include
using namespace std;
int main()
{
int a,b,c;
int f(int x,int y,int z);
cin>>a>>b>>c;
c=f(a,b,c);
cout<
return 0;
}
int f(int x,int y,int z)
{
int m;
if (x
else m=y;
if (z
return(m); 完美WORD格式
专业整理 知识分享 }
1.8题
#include
using namespace std;
int main()
第1章程序设计和C语言1
什么是计算机程序1
什么是计算机语言1
语言的发展及其特点3
最简单的C语言程序5
最简单的C语言程序举例6
语言程序的结构10
运行C程序的步骤与方法12
程序设计的任务14
1-5 #include <>
int main ( )
{ printf ("**************************\n\n");
printf(" Very Good!\n\n");
printf ("**************************\n");
return 0;
}
1-6#include <>
int main()
{int a,b,c,max;
printf("please input a,b,c:\n");
scanf("%d,%d,%d",&a,&b,&c);
max=a;
if (max
max=b;
if (max
printf("The largest number is %d\n",max);
return 0;
}
第2章算法——程序的灵魂16
什么是算法16
简单的算法举例17
算法的特性21
怎样表示一个算法22
用自然语言表示算法22
用流程图表示算法22
三种基本结构和改进的流程图26
用NS流程图表示算法28
用伪代码表示算法31
用计算机语言表示算法32
结构化程序设计方法34
习题36
第章最简单的C程序设计——顺序程序设计37
顺序程序设计举例37
数据的表现形式及其运算39
常量和变量39
数据类型42
整型数据44
字符型数据47
浮点型数据49 怎样确定常量的类型51
运算符和表达式52
语句57
语句的作用和分类57
最基本的语句——赋值语句59
数据的输入输出65
输入输出举例65
有关数据输入输出的概念67
用printf函数输出数据68
用scanf函数输入数据75
字符数据的输入输出78
习题82