第一范文网 - 专业文章范例文档资料分享平台

计算概论2009期末考试试题

来源:用户分享 时间:2025/5/24 16:32:44 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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期末考试试题 的文档
计算概论2009期末考试试题.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1og4q8h0xr9mzf00wd2v_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top