二级第11套

blank
#include <stdio.h>
double f1(double x)
{ return xx; }
double f2(double x, double y)
{ return x
y; }
double fun(double a, double b)
{
/found/
double (f)();
double r1, r2;
/found/
f = f1 ;
r1 = f(a);
/found/
f = f2 ;
r2 = (f)(a, b);
return r1 + r2;
}
void main()
{ double x1=5, x2=3, r;
r = fun(x1, x2);
printf("\nx1=%f, x2=%f, x1
x1+x1
x2=%f\n",x1, x2, r);
}
modi
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct aa
{ int data;
struct aa *next;
} NODE;
int fun (NODE h)
{ int sum=0;
NODE p;
p=h->next;
/found
/
while(p!=NULL)
{ if(p->data%2==0)
sum+=p->data;
/found
/
p=p->next;
}
return sum;
}
NODE *creatlink(int n)
{
NODE *h,p,s;
int i;
h=p=(NODE
)malloc(sizeof(NODE));
for(i=1;i<n;i++)
{
s=(NODE
)malloc(sizeof(NODE));
s->data=rand()%16;
s->next=p->next;
p->next=s;
p=p->next;
}
p->next=NULL;
return h;
}
void outlink(NODE *h)
{ NODE *p;
p=h->next;
printf("\n\n The LIST :\n\n HEAD");
while§
{ printf("->%d",p->data);
p=p->next;}
printf("\n");
}
void main()
{ NODE *head; int sum;
system(“CLS”);
head=creatlink(10);
outlink(head);
sum=fun(head);
printf("\nSUM=%d",sum);
}
prog
#include <stdio.h>
#define N 80
int fun(char *str)
{
int i,n=0,fg=1;
char *p=str;
while (*p)
{
n++;
p++;
}
for(i=0;i<n/2;i++)
if(str[i]==str[n-1-i]) ;
else
{
fg=0;
break;
}
return fg;
}

void main()
{
char s[N];
FILE out;
char test[]={“1234321”,“123421”,“123321”,“abcdCBA”};
int i;
printf(“Enter a string : “);
gets(s);
printf(”\n\n”);
puts(s);
if(fun(s))
printf(“YES\n”);
else
printf(“NO\n”);
/
**********************************/
out=fopen(“out.dat”,“w”);
for(i=0;i<4;i++)
if(fun(test[i]))
fprintf(out,“YES\n”);
else
fprintf(out,“NO\n”);
fclose(out);
/************************************/
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值