|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <math.h>
int main()
{
int sign = 1,count = 0;
double pi = 0.0,n = 1.0,term = 1.0;
while(fabs(term)>=1e-6);
{
pi = pi+term;
n = n+2;
sign = -sign;
term = sign/n;
count++;
}
pi = pi*4;
printf("pi = 10.8f%d\n",pi);
printf("count = %d\n",count);
return 0;
}
编译无问题,可以运行,但是编译半天也不见输入东西。求解怎么回事啊。用的visual C++6.0
本帖最后由 baige 于 2020-8-28 23:11 编辑
百年孤独i 发表于 2020-8-28 23:07
#include
int main()
{
两个else if后面的分号去掉
- #include <stdio.h>
- int main()
- {
- char c;
- int letters = 0,space = 0,digit = 0,other = 0;
- printf("请输入一串字符:\n");
- while((c=getchar())!='\n')
- {
- if(c>='a' && c<='z'||c>='A' && c<='Z')
- letters++;
- else if(c==' ')
- space++;
- else if(c>='0' &&c<='9')
- digit++;
- else
- other++;
- }
- printf("字母数:%d\n空格数:%d\n数字数:%d\n其他字符数:%d\n",letters,space,digit,
- other);
- return 0;
- }
复制代码
|
|