1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
int main()
{
int x,score;
printf("请输入成绩:");
scanf_s("%d", &score);
x = score / 10;
if (score < 0 && score>100)
printf("非法输入");
else
switch(x)
{
case 10:case 9:printf("A"); break;
case 8:printf("B"); break;
case 7:printf("C"); break;
case 6:printf("D"); break;
case 5:case 4:case 3:case 2:case 1:case 0:printf("E"); break;
default:printf("非法输入");
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<malloc.h>
#include<stdio.h>
typedef struct node
{
int data;
struct node *next;
}NODE;

NODE *create()
{
NODE *head,*q,*p;
char ch;
int a;
head=(NODE*)malloc(sizeof(NODE));
q=head;
ch='*';
printf("\nInput the list :");
while(ch!='?')
{
scanf("%d",&a);
p=(NODE*)malloc(sizeof(NODE));
p->data=a;
q->next=p;
q=p;
ch=getchar();
}
q->next=NULL;
return(head);
}

NODE *locate(NODE *head,int x)
{
NODE *p;
p=head->next;
while((p!=NULL)&&(p->data!=x))
p=p->next;
return(p);
}

void main()
{
int y,i=1;
NODE *a,*b;
a=create();
printf("Input x: ");
scanf("%d",&y);
b=locate(a,y);
if(b!=NULL)
{ printf("find:");
printf("%5d\n",b->data);

}
else
printf("error");
}