求助急急~~,C语言题目
发布网友
发布时间:2022-05-24 06:51
我来回答
共3个回答
热心网友
时间:2023-10-06 03:36
#include <stdio.h>
int main()
{
char str[100] = {0};
int count = 0, i, temp = 0, flag = 0;
gets(str);
for (i = 0; str[i] != '\0'; i++)
{
if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z'))
{
count++;
}
else
{
if (count > temp)
{
flag = i - count;
temp = count;
}
count = 0;
}
}
if (count > temp)
{
flag = i - count;
temp = count;
count = 0;
}
for (i = flag; i < temp + flag; i++)
{
printf("%c", str[i]);
}
return 0;
}
热心网友
时间:2023-10-06 03:37
等我看下书复习一下
热心网友
时间:2023-10-06 03:37
#include "stdio.h"
#define PI 3.14159
void main()
{
float r;
char t; //t为一个字符,而非字符串
char na,nb,nc; //na,nb,nc为字符型而非整型数据
void mianji(float r);
void zhouchang(float r);
na='a';
nb='b';
nc='c';
printf("Please input the radius r:\n");
scanf("%f",&r);
printf("Please input the mark:\n");
scanf("%s",&t); //对字符赋值,要用'&'号
if (na==t) mianji(r); //na等于t所代表的数据,而非字符t,所以单引号不能要
else if(nb==t) zhouchang(r);
else if(nc==t)
{
mianji(r);
zhouchang(r);
}
else printf("Input error!");
}
void mianji(float r)
{float s;
s=(float)(PI*r*r);
printf("s=%.4f\n",s);
}
void zhouchang(float r)
{float l;
l=(float)(2*PI*r);
printf("l=%.4f\n",l);
}