c语言实验报告1答案,郑州大学C语言实验报告答案

41528d3028836879cd698677c3999917.gif郑州大学C语言实验报告答案

郑州大学C语言实验报告答案 实验一 1、 #include void main() { int a,b,c; scanf(“%d,%d,%d“, printf(“sum=%d\n“,a+b+c); }2、 #include void main() { int a,b,he,cha,ji,shang; scanf(“%d,%d“, he=a+b; cha=a-b; ji=a*b; shang=a/b; printf(“he=%d\n“,he); printf(“cha=%d\n“,cha); printf(“ji=%d\n“,ji); printf(“shang=%d\n“,shang); }3、 #include void main() { int a,b,c,d,e,sum; scanf(“%d,%d,%d,%d,%d“, sum=a*a+b*b+c*c+d*d+e*e; printf(“sum=%d\n“,sum); } 4#include include void main() { double a,b,c,sum; scanf(“%lf,%lf,%lf“, sum=sqrt(a)+sqrt(b)+sqrt(c); printf(“sum=%f\n“,sum); } 5、 #include #define PI 3.14159 void main() { float r,l,s; printf(“请输入圆半径(r):“); scanf(“%f“, l=2*PI*r; s=r*r*PI; printf(“\n圆周长 l=%6.2f\n“,l); printf(“圆面积 s=%6.2f\n“,s); } 6、 #include void main() { printf(“\“what a beautiful campus!\“\n“); printf(“\“I wish you every success!\“\n“); } 实验二 1、#include void main() { int a,b,c;float x; scanf(“a=%d,b=%d,c=%d,x=%f“, printf(“%f“,a*x*x*x+b*x*x+c); } 2、#include void main() { int a,b; scanf(“a=%d,b=%d“, printf(“ji=%d,shang=%d,yushu=%d“,a*b,a/b,a%b); }3、 #include void main() { float c,f; printf(“请输入一个华氏温度f:“); scanf(“%f“, c=5.0/9.0*(f-32); printf(“\n摄氏温度为: %5.2f\n“,c); } 4、 #include #define PI 3.14159 void main() { float r,l,s; printf(“请输入圆半径(r):“); scanf(“%f“, l=2*PI*r; s=r*r*PI; printf(“\n圆周长 l=%6.2f\n“,l); printf(“圆面积 s=%6.2f\n“,s); } 5、 #include void main() { float c=3.123456789; printf(“%f“,c); } 6、#include void main() { int a=2; a+=a; printf(“%d\n“,a); a-=2; printf(“%d\n“,a); a*=2+3; printf(“%d\n“,a); a/=a+a; printf(“%d\n“,a); 实验三 1、#include void main() { int a=3,b=4,c=5; float x=1.414,y=1.732,z=2.712; printf(“a=%-7d b=%-7d c=%-7d\nx=%-7.3f y=%-7.3f z=%-7.3f“,a,b,c,x,y,z); } 2、#include void main() { int a,b,c; float x,y,z; scanf(“%d“, scanf(“%d“, scanf(“%d“, scanf(“%f“, scanf(“%f“, scanf(“%f“, printf(“a=%d,b=%d,c=%d\nx=%.3f,y=%.3f,z=%.3f,\n“,a,b,c,x,y,z); } 3、#include void main() { int a,b,c,x1,x2; scanf(“%d,%d,%d“, x1=a+b+c; x2=a-b-c; printf(“x1=a+b+c=%d+%d+%d=%d\n“,a,b,c,x1); printf(“x2=a-b-c=%d-%d-%d=%d\n“,a,b,c,x2); } 4、#include void main() { char c1,c2,c3,c4; scanf(“%c%c%c%c“, printf(“%d,%d,%d,%d“,c1,c2,c3,c4); } 5、#include void main() { int d1=60,d2=61,d3=62,d4=63; printf(“%c,%c,%c,%c“,d1+5,d2+5,d3+5,d4+5); } 6、#include

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为您提供一份栈的链式表示和实现C语言实验报告。 实验目的:了解栈的链式表示和实现过程,掌握链表的基本操作。 实验内容:设计一个栈的链式存储结构,并实现入栈、出栈等基本操作。 实验步骤: 1. 定义结构体,包括存储数据的成员和指向下一个节点的指针成员。 ``` typedef struct node { int data; struct node *next; } Node; ``` 2. 定义栈顶指针,并初始化为空。 ``` Node *top = NULL; ``` 3. 实现入栈操作,即在链表头部插入节点。 ``` void push(int value) { Node *new_node = (Node *) malloc(sizeof(Node)); new_node->data = value; new_node->next = top; top = new_node; } ``` 4. 实现出栈操作,即删除链表头部节点。 ``` int pop() { if (top == NULL) { printf("Stack is empty.\n"); return -1; } int value = top->data; Node *temp = top; top = top->next; free(temp); return value; } ``` 5. 实现打印栈中元素的操作。 ``` void print_stack() { if (top == NULL) { printf("Stack is empty.\n"); return; } Node *current = top; printf("Stack: "); while (current != NULL) { printf("%d ", current->data); current = current->next; } printf("\n"); } ``` 6. 在主函数中调用上述操作,测试栈的功能。 ``` int main() { push(1); push(2); push(3); print_stack(); // output: Stack: 3 2 1 pop(); print_stack(); // output: Stack: 2 1 push(4); print_stack(); // output: Stack: 4 2 1 return 0; } ``` 实验结果:成功实现了栈的链式存储结构,并实现了入栈、出栈和打印栈中元素的基本操作。 以上就是栈的链式表示和实现C语言实验报告,希望对您有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值