急!急!急!用C语言编写一个程序,输入若干个整数,以-1标记结束,输出其中...
include <stdlib.h> int main(){int max,min,num;printf("Input numbers,-1 to end:\\n");scanf("%d",&num);max=min=num;while(num!=-1){ if(num>max)max=num;if(num<min)min=num;scanf("%d",&num);} printf("max:%d,min:%d\\n",max,min);system("pause");return 0;} ...
c语言: 输入若干个整数,以-1标记输入结束。输出其中的最大数...
int arr[n];\/\/n为输入的整数的个数 int i;max=arr[0];for(i=0;i<n-1;i++){ scanf("%d",arr[i]);\/\/输入前n-1个数 } arr[i]=-1;\/\/以-1结束 for(i=0;i!=1n;i++){ if(arr[i]>max) max = arr[i];\/\/求最大值 } 这是核心语句,我希望你可以自己加上程序框架,...
c语言,从键盘输入若干个整数,用-1作为输入结束的标志,求他们的和及平均...
include<stdio.h> int main(){ int x;double sum=0,pj;int cnt=0;scanf("%d",&x);while(x!=-1){ sum+=x;cnt++;scanf("%d",&x);} if(cnt>0){ pj=sum\/cnt;printf("%.2f\\n",pj);} return 0;}
c语言输入若干个整数输入是-1时,输入结束;后计算所有元素之和及平均值...
return 0;}
C语言如何求输入任意几个数中的最大值,输入-1结束?
include<stdio.h> int main(){ double n,max;scanf("%lf",&n);max=n;while(n>=0){scanf("%lf",&n);if(max<n)max=n;} printf("%lf",max);return 0;}
C++或者C写一个程序,写个求总和的函数:从键盘输入若干个数,以-1为...
include<stdio.h>int fsum() { int s=0,x; while ( 1 ) { scanf("%d",&x); if ( x==-1 ) break; s+=x; } return s;}void main() { int s; s=fsum(); printf("%d\\n",s);}
c语言程序编译,帮忙做吧...从键盘上输入若干个数,以-1结束,按照与输入...
include<stdio.h> int getMax(int a,int b,int c){ return a>b? a:(b>c? b:c);} int getMin(int a,int b,int c){ return a<b? a:(b<c? b:c);} void main(){ int a,b,c;printf("Please input three numbers:\\n");scanf("%d",&a);scanf("%d",&b);scanf("%d"...
用C语言编程:输入一组整数,以-1作为结束的标志,用数组s接收这组数...
include<stdio.h> int main(){ int n = 0, m = 0,s[];for(;n != -1;){ scanf("%d",&n);s[i]=n;i++;m = m + 1;} printf("个数为:%d\\n",m);for(int i=0;i<m;i++)printf("%d\\n",s[i]);return 0;} ...
输入若干数以-1结束 C语言
include <stdio.h>int main(void){int n,pcnt,ncnt,zcnt,psum,nsum;for(pcnt=ncnt=zcnt=psum=nsum=0;scanf("%d",&n)==1&&n!=-1;){if(n>0){pcnt++;psum+=n;}else{if(n<0){ncnt++;nsum+=n;}else{zcnt++;}}}printf("%d %d %d\\n",pcnt,zcnt,ncnt);printf("%d ...
c语言中某一门功课的程序统计,输入若干个同学的成绩。以-1作为输入终 ...
include\\x0d\\x0aint main()\\x0d\\x0a{\\x0d\\x0afloat std[100],sum=0;\\x0d\\x0aint i=0,num;\\x0d\\x0aprintf("输入学生成绩,以-1结束:");\\x0d\\x0afor(;i<100;i++)\\x0d\\x0a{\\x0d\\x0ascanf("%f",&std[i]);\\x0d\\x0aif(std[i] == -1) break;\\x0d\\...