#include
#define MAX 2000
void main()
{
int num[MAX],n,i=-1,flag=1;
printf("请输入一串整数,以-9999结束:\n");
do
{
i++;
scanf("%d",&num[i]);
}while((i<=MAX) && (num[i]!= -9999));
printf("请输入另一个整数:\n");
scanf("%d",&n);
for(i=0;i
if(num[i] == n)
{
printf("yes,in number %d.\n",i);
flag=0;
}
}
if(flag)
printf("no.\n");
}
#include
#include
int main()
{
int a[2001],i,n;
printf("请输入整数,-9999为结束\n");
for(i=0; i<2001; i++)
{
scanf("%d",&a[i]);
if(a[i]==-9999)break;
}
printf("请输入n\n");
scanf("%d",&n);
for(i=0; a[i]!=-9999; i++)
{
if(a[i]==n)
{
printf("yes 序号:%d\n",i);
break;
}
}
if(a[i]==-9999)printf("no\n");
return 0;
}
#include
#define MAX 2000
void main()
{
int a[MAX],m,n,i;
printf("Input some integers:\n");
for(i=0;i
if(a[i] == 9999)break;
}
printf("Input an integer:\n");
scanf("%d",&n);
for(m=0;m
printf("yes,序号为:%d",m);
break;
}
if(a[m] == 9999){
printf("no");
break;
}
}
}
#include
#include
typedef struct _DATA
{
int data;
struct _DATA *next;
}DATA;
int main()
{
int i = 0,j = 0;
DATA * p = 0, *tmp = 0;
int d = 0;
while(1)
{
scanf("%d",d);
if(d = -9999) break;
tmp = (DATA *)calloc(1,0,sizeof(DATA));
tmp->data = d;
if(p == 0)
{p = tmp; }
else
{tmp->next = p;
p = tmp;}
i++;
}
scanf("%d",d);
j = i;
tmp = p;
while(j < i)
{
if(tmp->data == d)break;
j++;
}
if(j == i)
{
printf("No Found!\n");
}
else
{
printf("No: %d",i - j)
}
tmp = d;
while(tmp)
{
d = d->next;
free(tmp);
tmp = d;
}
return 0;
}
顶一楼,其他人都有错。