C语言程序设计题!!!急!!!

2024-11-22 20:50:00
推荐回答(1个)
回答(1):

1.
#include
#include

int strSearch(char *str[], char *str_sea, int len);

char *str[] = {"abc", "bcd", "xyz", "bcdef", "bcde"};
char *str1 = "bcde";

main()
{
int len = sizeof(str)/sizeof(char *);
printf("%d\n" ,strSearch(str, str1, len));
}

int strSearch(char *str[], char *str_sea, int len)
{
//int len = sizeof(str)/sizeof(char *);
//printf("len: %d \n", len);
int i = 0;
for(i = 0; i < len; i++)
{
if(strcmp(str[i], str_sea) == 0)
{
return 1; }
}
return 0;
}

3.
#include
#include

float func1(float V0, float Q)
{
return 2*9.8*V0*sin(3.14/180*Q);
}

float func2(float V0, float Q)
{
return 9.8*V0*sin(3.14/180*Q);
}

main ()
{
float V0;
float Q;
printf("请输入初速度:");
scanf("%f", &V0);
printf("请输入角度:");
scanf("%f", &Q);
printf("2*Vo*sinQ: %f\n", func1(V0, Q));
printf("请输入初速度:");
scanf("%f", &V0);
printf("请输入角度:");
scanf("%f", &Q);
printf("Vo*sinQ: %f\n", func2(V0, Q));
}