华为oj ----求圆的面积


  • 题目背景

计算半径为110的圆的面积,若面积在4090之间请输出

  • 接口

int OutPutRotundityAreafloat* pResultArrayint &ArrayCount

float* pResultArray :float型数组

Int ArrayCount数组长度

  • 规格

要求时间复杂度为O(n)

     π = 3.14 


#include <stdlib.h>
#include <string.h>
#include "oj.h"
#define PI 3.14

/*
功能:
    
输入: 
    
输出:	arrValue:存储返回的符合范围之内的圆面积,内存在函数外已经申请 
		nValue:返回数组的行数
     
返回: 
     
*/

void OutputRotundityArea(float *arrValue,int &nValue)
{
	if (NULL==arrValue|| NULL ==&nValue) {
		return;
	}
	 nValue = 0;
	for (int i = 0; i <= 10;i++) {
		if (((PI*i*i) >= 40) && ((PI*i*i) <= 90))
		{
			arrValue[nValue]= (float)(PI*i*i);
			nValue++;
		}
	}
	return;

}

  • 题目背景

计算半径为110的圆的面积,若面积在4090之间请输出

  • 接口

int OutPutRotundityAreafloat* pResultArrayint &ArrayCount

float* pResultArray :float型数组

Int ArrayCount数组长度

  • 规格

要求时间复杂度为O(n)

     π = 3.14 

猜你喜欢

转载自blog.csdn.net/nameix/article/details/80328046
今日推荐