一个接一个地输入一批数字,-1作为结束标志。计算并输出这些数中大于10的数字,并统计大于10的数字个数

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:52:42
本人是C语言初级学者,要求写的程序要有说明,两个题请各位高手尽快做出来。

#include<stdio.h>
int main()
{
int temp,tot;
tot=0;
while(scanf("%d",&temp),temp!=-1)
{
if(temp>10){printf("%d ",temp); tot++;}
}
printf("the number >10:%d",tot);
return 0;
}

二而一提亚瑞特有人跳页

#include<iostream>
using namespace std;
void main()
{
int n,k=0;
while(n!=-1)
{
cin>>n;
if(n>10)
{
cout<<n<<' ';
k++;
}
}

cout<<'\n'<<k<<endl;
}