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

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

来源:网络收集 时间:2025-09-20
导读: #include\void main() { int m,n,a; cout >m,n; a=Fabricate(m,n); cout /*/ e15 #include void findmin(int[],int); void main() { int a[10]={34,91,83,56,29,93,56,12,88,72}; for (int i=0;i void findmin(int

#include\void main() { int m,n,a;

cout<<\cin>>m,n;

a=Fabricate(m,n); cout<

/*/ e15

#include void findmin(int[],int); void main()

{ int a[10]={34,91,83,56,29,93,56,12,88,72}; for (int i=0;i<10;i++) cout<

void findmin(int x[],int n) { int k,t=0;

for(int i=t+1;i

/*34 91 83 56 29 93 56 12 88 72 第11位数最小,为:12 neworder:

12 91 83 56 29 93 56 34 88 72 Press any key to continue */

/*/ e16

#include void ins(int [],int,int);

void main() { int n;

int a[10]={0,1,2,3,4,5,6,7,8,9}; for(int i=0;i<10;i++) cout<>n; ins(a,n,10); for(i=0;i<10;i++) cout<

void ins(int x[],int n,int num) { int min,t; if(x[num-1]>n) {cout<

for(int i=0;i<(num-1);i++) {t=i; for(int j=i+1;j

else cout<

0 1 2 3 4 5 6 7 8 9 n=8 9

0 1 2 3 4 5 6 7 8 8

Press any key to continue*/

/*/ e17

#include

int*findmax(int*array,int size,int& index); int*ipt; void main()

{int a[10]={33,54,91,67,82,37,85,63,19,68}; int*maxaddr;int idx;

for(int i=0;i<10;i++)cout<

cout<<\ <<\ <<\int*findmax(int*array,int size,int&index) { index=0; for(int i=1;i

if(array[i]>array[index])index=i; if(index!=0)

return array+index; } //*/ /*

0 0x0012FF58 33 1 0x0012FF5C 54 2 0x0012FF60 91 3 0x0012FF64 67 4 0x0012FF68 82 5 0x0012FF6C 37 6 0x0012FF70 85 7 0x0012FF74 63 8 0x0012FF78 19 9 0x0012FF7C 68 the index of maximum elemen is:2 the address of it is:0x0012FF60 the value of it is:91

Press any key to continue */ /*/e18

#include #include

int strcmp(const char* str1,const char* str2) { if (strlen(str1)!=strlen(str2)) { if (strlen(str1)>strlen(str2)) return 1; else return -1; } else { int t=strlen(str1);

for(int i=0;istr2[i]) return 1; if (str1[i]

void main() { char *a=\ char *b=\ cout<

Press any key to continue*/ //*/

/*e19

#include #include #include

int fcmpa(const void* a1,const void* b1) { return (*(int *)b1+*(int *)b1/10)-(*(int *)a1+*(int *)a1/10); }

int fcmpb(const void* a2,const void* b2) { return *(double

*) a2 > *(double *) b2 ? 1 : -1; }

int fcmpc(const void* a3,const void* b3) {

if(strlen(*(char**)a3)==strlen(*(char**)b3)) return strcmp(*(char**)a3, *(char**)b3); return strlen(*(char**)a3)-strlen(*(char**)b3); }

void main() { int a[10]={12,32,42,51,8,16,51,21,19,9};

double b[10]={32.1,456.87,332.67,442.0,98.12,451.79,340.12,54.55,99.87,72.5}; char* c[]={\ qsort(a,10,sizeof(int),fcmpa); cout<<\ for(int i=0;i<=9;i++) cout<

)/sizeof(*c),sizeof(*c),fcmpc); cout<<\ for(int k=0;k<=9;k++) cout<

a[i]after:19 9 8 16 42 51 51 32 21 12

b[i]after:32.1 54.55 72.5 98.12 99.87 332.67 340.12 442 451.79 456.87 c[i]after:a of cap cat size begin enter number certain program Press any key to continue*/

/*/ e20

#include #include using namespace std; void main() { ifstream fin (\ char ch[200]; fin>>ch; while(ch[0]!='\\0') { cout<>ch; } cout<

} //*/

//blue.txt

//This is a test. //Answer: //Thisisatest.

…… 此处隐藏:509字,全部文档内容请下载后查看。喜欢就下载吧 ……
C++作业题与答案(4).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)