我正在尝试使用我的程序获得圆形区域.但是区域不是小数.
#include<iostream>
using namespace std;
float AreaOfCircle(float r);
int AreaOfCircle(int r);
int main()
{int rad;
cout<<"Enter the Radius of Crircle: ";
cin>>rad;
cout<<"The Are of the Cirlcle: "<<AreaOfCircle(rad);
}
float AreaOfCircle(float r)
{
int area=0;
area=2*3.1456*r*r;
return area;
}
int AreaOfCircle(int r)
{
int area=0;
area=2*3.1456*r*r;
return area;
}
Run Code Online (Sandbox Code Playgroud)
但我需要回答一些小数点.
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char str[80];
int i=0;
cout<<"Enter the String ";
gets(str);
for (int j=0;str[j]!='\0';j++)
if (str[i]=='A'||'E'||'I'||'O'||'U')
i++;
cout<<"Number of vowels is: "<<i;
}
Run Code Online (Sandbox Code Playgroud)
这里我是元音字符串中的元素检查元素,有人可以为此建议替代方法吗?我需要计算字符串中的元音数量.
这段代码对我来说很完美,只需要找到替代方法,我不必输入太多"||" 和'a'和'A'不同.