程序要求输入,然后不显示任何输出。

编程入门 行业动态 更新时间:2024-10-24 21:28:19
本文介绍了程序要求输入,然后不显示任何输出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

#include<stdio.h> main() { int scores[3], sum; float avg; printf("enter the value for scores\n"); scanf("%d\n %d\n %d\n",&scores[0],&scores[1],&scores[2]); sum=scores[0]+scores[1]+scores[2]; avg=sum/3; printf("The sum is :%d\n The avg is :%f\n",sum,avg); system("pause"); }

真正的计划是:

The real program is:

#include<stdio.h> main() { int scores[3],sum; float avg; printf("Enter Score 1 : "); scanf("%d",&scores[0]); printf("Enter Score 2 : "); scanf("%d",&scores[1]); printf("Enter Score 3 : "); scanf("%d",&scores[2]); sum=scores[0]+scores[1]+scores[2]; avg=sum/3; printf("Sum is = %d\nAverage = %f\n",sum,avg); system("pause");

我尝试过: 问题很大,我试图修剪它但输入3个输入时没有显示输出。

What I have tried: The problem is big and I tried to trim it but it is showing no output when I enter 3 inputs.

推荐答案

它适用于我: It works fine for me: enter the value for scores 10 20 30 The sum is :60 The avg is :20 Sum is = 60 Average = 20

并且

Enter Score 1 : 10 Enter Score 2 : 20 Enter Score 3 : 30 Sum is = 60 Average = 20

检查您是否正在运行正确的可执行文件...并尝试摆脱系统(暂停)行。

#include<stdio.h> int main(void) { int scores[3], sum; float avg; printf("enter the value for scores\n"); scanf("%d%d%d",&scores[0],&scores[1],&scores[2]); sum=scores[0]+scores[1]+scores[2]; avg=sum/3.0; printf("The sum is :%d\n The avg is :%f\n",sum,avg); return 0; }

更多推荐

程序要求输入,然后不显示任何输出。

本文发布于:2023-07-05 06:53:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034361.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!