c语言简单编程练习题.docVIP

  • 4
  • 0
  • 约7.67千字
  • 约 25页
  • 2023-10-05 发布于浙江
  • 举报
c语言简单编程练习题 精品文档 c语言简单编程练习题 然后输出相应的字符。 #include #include main { int i, j; char c; printf; scanf; while { if) { printf; c=toascii; printf; printf; scanf; } else { 1 / 25 精品文档 printf; break; } } return 0; } 2.功能描述:编写函数,实现对10个整数按由小到达排序,在主函数中调用此函数。 *要 求:完成至少3个函数分别实现插入排序、选择排序、冒泡排序 #include #define M 10 void insert; void choice; void BubbleSort; void print; void main { int a[M], i; printf; for { scanf; } 2 / 25 精品文档 printf; for { printf; } printf; insert;//插入排序 print; printf; for { scanf; } printf; for { printf; } printf; choice; //选择排序 print; printf; 3 / 25 精品文档 for { scanf; } printf; for { printf; } printf; BubbleSort;//冒泡排序 print; } void insert //插入排序 { int i, j, k, temp; for { for { if { 4 / 25 精品文档 temp = a[j]; a[j] = a[j-1]; a[j-1] = temp; } else { break; } } } } void choice //选择排序 { int i, j, temp = 0, t=0; for { t = i; for { if { t = j; 5 / 25 精品文档 } } temp = a[i]; a[i] = a[t]; a[t] = temp; } } void BubbleSort { int i, j, temp; for { for { if { temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } } 6 / 25 精品文档 } void print { int i; printf; for { printf; } printf; } 3. 已知head指向一个带头结点的单向链表,链表中每个结点包含数据域和指针域。 请编写函数实现如图所示链表逆置。 要求: 不开辟任何额外的链表结点空间,实现链表的就地逆置 考察: 对链表结构的基本操作 #include #include #include #include #define LEN sizeof 7 / 25 精品文档 struct sth { char a[20]; struct sth *next; }; struct sth *creat; struct sth *exchange; void print; void free1; void main { struct sth *head; printf;head = creat; printf;print; exchange; printf;print; free1; } struct sth *creat { struct sth *head = NULL; struct sth *p1, *p2; char input[10]={‘\0’}; // p1 = p= malloc; ? 马克思手稿中有一道趣味数学题:有30个人,其 8 / 25 精品文档 中有男人、女人和小孩,在一家饭馆里吃饭 共花了50先令,每个男人各花3先令,每个女人各花2先令,每个小孩各花1先令,问男人、女人和小孩各有几人, 解方程组 编写程序,采用穷举法求出结果。 ? 编写程序,根据以下公式求e的值。要求用两种方法计算: 111111 1) for循环,计算前50项 2)while 循环,直至最后一项的值小于10-4 e?1?????????????1!2!3!4!5!n! ?

文档评论(0)

1亿VIP精品文档

相关文档