云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 计算概论2009期末考试试题

计算概论2009期末考试试题

  • 62 次阅读
  • 3 次下载
  • 2025/5/2 2:47:59

2.

void main(void) {

static char s[]=\wbc\; int m, a=0, b=0, c=0;

for (m=0;s[m]!=?\\0?; m++)

switch (s[m]) {

case 'c' : c++ ; case 'b' : b++ ; default: a++; }

printf(\ }

五 阅读下列程序,在空格处填入适当内容,使程序完整。(每空2分,30分) 1.用选择法对数组中的10个字符按由大到小排序。 void sort(char a[ ], int n) { int i,j,k;

char t;

for (i=0;i

main( ) {

char s[10]; int i;

5

for(i=0;i<10;i++) scanf(\ (3) ;

printf(\ for(i=0;i<10;i++) printf(\(4) ); printf(\}

(1) (2) (3) (4) 2.用“起泡法”对输入的10个字符排序后按从小到大的次序输出 #define N 10 char str[N];

void sort(char str[];)

main() {

int i, flag;

for(i=0;i<10;i++) scanf(\ sort( (5) ); for(i=0;i

void sort(char str[N];) { int i,j; char t;

for (j=1;j (6) ) {

t=str[i];

(7) ; (8) ; } }

(5) (6) (7) (8)

6

3.用单向循环链表求解约瑟夫环问题: 用户输入M,N值,从1至N开始顺序循环数数,每数到M输出该数值,直至全部输出。(注: 单向循环链表的尾节点指针指向头节点。) #include #include #include struct node {

int num;

struct node *next; };

struct node * circle_create(int n) {

struct node *p_header = NULL; struct node *p_node = NULL; struct node *p_tail = NULL; int num;

(9) ; if (p_node ==NULL) return NULL;

p_node->num = 1; p_header = p_node;

p_header->next = p_header; p_tail = p_node;

for (num=2; num <= n; num++) {

p_node = (struct node *) malloc(sizeof(struct node)); p_node->num = num;

p_node->next = p_header;; (10) ; p_tail = p_node; }

7

return p_header; }

void main() {

int n, m;

struct node *p_node, *p_header, *p_temp; printf(\ scanf(\

printf(\key is : %d \\n\

(11) ;

p_node= p_header;

while ( (12) ) {

int i = 1;

for (; i < m - 1; i++) {

(13) ; }

printf(\

p_temp = p_node->next; (14) ; (15) ; free(p_temp); }

printf(\ free(p_header); }

(9) (10) (11) (12) (13) (14) (15)

8

搜索更多关于: 计算概论2009期末考试试题 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

2. void main(void) { static char s[]=\wbc\; int m, a=0, b=0, c=0; for (m=0;s[m]!=?\\0?; m++) switch (s[m]) { case 'c' : c++ ; case 'b' : b++ ; default: a++; } printf(\ } 五 阅读下列程序,在空格处填入适当内容,使程序完整。(每空2分,30分) 1.用选择法对数组中的10个字符按由大到小排序。 void sort(char a[ ], int n) { int i,j,k; char t; for (i=0;

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com