#include <iostream>
#include <cctype>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
double donation[10];
int len , i , j;
double sum , average , num;
string line;
cout << "Enter 10 donation!" << endl;
for(i = 0;i < 10;i++)
{
getline(cin , line ,'\n');
len = line.size();
for(j = 0;j < len;j++)
{
if(isdigit(line[j]) == false && ispunct(line[j] == false))
{
cout << "not digit!" << endl;
}
}
donation[i] = atof(line.c_str());
sum += donation[i];
}
average = sum / i;
for(i = 0;i < 10;i++)
{
if(donation[i] > average)
{
num++;
}
}
cout << "The average = " << average << endl;
cout << "In this array has " << num << " large than avearge" << endl;
return 0;
}
c++ 判断输入的一个double数的每一位是不是阿拉伯数字
最新推荐文章于 2022-10-27 23:33:22 发布