C语言试题 请教请教

来源:百度知道 编辑:UC知道 时间:2024/06/06 09:04:12
1.设x和y均为int型变量,则执行下面的循环后,y的值为( )。
for(y=1,x=1;y<=50;y++)
{ if (x>=10)break;
if (x%2==1)
{ x+=5;continue;}
x-=3;
}

2、设有以下结构类型说明和变量定义,则变量a在内存所占字节数是____________。
struct stud
{ char num[5];
int s[2];
double ave;
} a,*p;

3、 写一个用函数调用来实现统计字符串中某字符的出现次数的程序。例如:调用f1(“every”,’e’)后返回2,因为在字符串”every”中字符’e’出现了2次。字符串和要统计的字符用scanf函数在主函数中输入,并在主函数中输出该字符在字符串中出现的次数。

4、 编一个程序,输入10个整数,统计并输出其中正数、负数和零的个数。

5、 下面的函数用来求“昨天”(相对于参数today)是星期几,请补充完整其中的return语句:
enum WEAKDAY{Sun,Mon,Tue,Wed,Thu,Fri,Sat};
WEAKDAY yestodayOf(WEAKDAY today){
If(today = = Sun)return_______(4)_______________;

7、 输入某年某月后,输出该月的天数。
main()
{ int year,month,day;
scanf("%d%d",&year,&month);
if (month<1||month>12)printf("Input Error\n");
else
{
swich (mo

4.
#include<stdio.h>

int main(void)
{
int i;
int num[10];
int countPost=0,countNeg=0,countZero=0;
printf("input first number:");
for(i=0;i<10;i++)
{

scanf("%d",&num[i]);
if(num[i]<0)
countNeg++;
else if(num[i]>0)
countPost++;
else
countZero++;
printf("input the next number:");
}
printf("the number of postive number is:%d\n",countPost);
printf("the number of negtive number is:%d\n",countNeg);
printf("the number of zero is :%d\n",countZero);
}

1 。 y=6
2 。 24
3 。 编程就先放下了 太长了

...

10 。 46
11 。 3