教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 建筑文档 >

C++作业题与答案(3)

来源:网络收集 时间:2025-09-20
导读: { int i,j,a,b; for(i=-3;i for(j=-3;j b)?cout 3 3 3 3 3 3 3 3 2 2 2 2 2 3 3 2 1 1 1 2 3 3 2 1 0 1 2 3 3 2 1 1 1 2 3 3 2 2 2 2 2 3 3 3 3 3 3 3 3 Press any key to continue*/ /*/ e9 ② #include #include

{ int i,j,a,b;

for(i=-3;i<=3;i++) { a=abs(i);

for(j=-3;j<=3;j++) { b=abs(j); (a>b)?cout<<\ } cout<

3 3 3 3 3 3 3 3 2 2 2 2 2 3 3 2 1 1 1 2 3 3 2 1 0 1 2 3 3 2 1 1 1 2 3 3 2 2 2 2 2 3 3 3 3 3 3 3 3

Press any key to continue*/

/*/ e9 ②

#include #include #include void main()

{signed i=4;int x,y=4; do

{x=(4-abs(i))*2;

for(cout<0;x--) cout<

if(i%2==0) y--;}while(i>=-4); } //*/ /*

4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1

1 1 1 0

Press any key to continue*/

/*/ e9 ③

#include #include #include void main() {signed i=4,j,x; do {j=4;

x=(4-abs(i))*2;

for(cout<

if(abs(i)>=abs(j)) cout< i--;}while(i>=-4); } //*/ /*

4 4 3 4 4 3 2 3 4 4 3 2 1 2 3 4 4 3 2 1 0 1 2 3 4 4 3 2 1 2 3 4 4 3 2 3 4 4 3 4 4

Press any key to continue*/ /*/ e10 递推法 #include void main() {int n,sum=0;

cout<<\cin>>n; if(n>=4)

{for(n=n-3;n>0;n--) sum=sum+1;}

cout<<\

//*/ /*

How many years? 10

The nunber of cow is 7 Press any key to continue*/ /*/ e10递归法 #include int cow(int); void main() {int n,x;

cout<<\cin>>n; x=cow(n);

cout<<\int cow(int n)

{if(n<=3) return 0; else return cow(n-1)+1 ;} /*

How many years? 10

The nunber of cow is 7 Press any key to continue*/

/*/ e11

#include

void fc(int n){if(!n)return;fc(n/10);cout<

void fe(int n){char s[]=\void ff(int a){if(!a)return;ff(a/10);fe(a);cout<<\void main()

{long a;cout<<\请输入一个无符号整数: \cout<<\ \\n\

cout<<\ \\n\cout<<\ \\n\} //*/ /*

请输入一个无符号整数: 789 (1) 7 78 789

(2) 987 (3)

0111 1000 1001

Press any key to continue //*/

/*/ e12

#include #include void print(int w)

{ if(w==1) cout<

for(int i=1; i<=w; i++) cout <

void main() {print(5);} //*/ /* 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

Press any key to continue*/ /*/ e13

#include #include void main()

{int m=0,n=0,t;double x,y; do

{x=10*n+6; t=pow(10,m);

if(n%t==0&&n!=0) m++; y=n+6*pow(10,m); n++;}while(y!=4*x);

cout<

615384=4*153846

Press any key to continue*/

/*/ e14 ① #include void display(double); void display(int); void display(char); void main()

{double a=3.14;int b=10; char c='W'; display(a); display(b); display(c); }

void display(double a)

{cout<<\void display(int b)

{cout<<\void display(char c)

{cout<<\//*/ /*

a double:3.14 a int:10 a char:W

Press any key to continue */

/*/ e14 ② // my function.h

int Fabricate(int m,int n) int Multi(int m,int n) // my Fabricate.cpp

int Fabricate(int m,int n) { int g

if (n==0&&m==n) return 1; else g=n*Fabricate(n-1); return Multi(m,n)/g; }

// my Multi.cpp

int Multi(int m,int n) {if (m=n) return 1;

else return m*Multi(m-1); }

// my main.cpp

#include

…… 此处隐藏:227字,全部文档内容请下载后查看。喜欢就下载吧 ……
C++作业题与答案(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/438500.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)