有3个程序设计的简单问题,求答案!是VC++的

来源:百度知道 编辑:UC知道 时间:2024/05/28 07:03:25
1.从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入。

2.输入若干字符,分别统计数字字符的个数、英文字母的个数,当输入换行符时输出统计结果,运行结束。

3.从键盘输入10整型数,统计其中负数个数并求所有正数的平均值。
只有5积分了 对不起啊

1、最高最低成绩
#include "iostream.h"

void main()
{
float high=0.0,low=100.0,score=0.0;
cout<<"输入成绩:"<<endl;
while(score>=0)
{
cin>>score;
if(score>high&&score<=100) high=score;
if(score<low&&score>=0) low=score;
}
if(high==0.0&&low==100.0)
cout<<"没有输入成绩!"<<endl;
else
cout<<"最高最低成绩分别为"<<high<<"和"<<low<<endl;
}

2、统计数字和字母
#include "iostream.h"

void main()
{
int num=0,letter=0;
char temp=0;
cout<<"输入数字或者字母,按回车结束输入!"<<endl;
while(temp!='\n')
{
temp=cin.get();
if((temp>=97&&temp<=122)||(temp>=65&&temp<=90)) letter++;
if(temp>=48&&temp<=57) num++;
}
cout<<"共有字母:"<<letter<<"个"<&