324日常学习
#include <stdio.h>
#include <string.h>
struct student
{
int num;
char name[20];
char sex;
float scoer;
}s1,s2;
void testlogin();
void testStrcat();
void testStrcatArr();
void testSaa();
void main()
{
testSaa();
/*s1.num=1;
s1.name[0]="lisi";
s1.sex='F';
s1.scoer=90;
s2=s1;
struct student s3={2,"zhangsan",'N',66};
printf("s3的学号是%d,姓名是%s,性别是%c,分数为%.1f\n",s3.num,s3.name,s3.sex,s3.scoer);
printf("-------------------------------------------\n");
printf("s1的学号是%d,姓名是%s,性别是%c,分数为%.1f\n",s1.num,s1.name,s1.sex,s1.scoer);
printf("-------------------------------------------\n");
printf("s2的学号是%d,姓名是%s,性别是%c,分数为%.1f\n",s2.num,s2.name,s2.sex,s2.scoer);*/
}
/*void str()
{
char stra[]="hello world!";
int len=strlen(stra);
printf("%s的长度为%d\n",stra,len);
char strb[0];
strcpy(strb,stra);
printf("复制到strb后是%s\n",strb);
} */
void testlogin()
{
char name[20],password[20],yzm[10];
printf("请输入用户id:");
gets(name);
printf("请输入密码:");
gets(password);
printf("请输入验证码:");
gets(yzm);
if(strcmpi(yzm,"ABCD")==0)
{
if(strcmp(name,"ljs")==0&&strcmp(password,"1147")==0)
{
printf("登陆成功!");
}else
{
printf("登陆失败");
}
}else
{
printf("你输入的验证码不正确!");
}
}
void testStrcat()
{
char a[]="zzsxt,",b[]="good!";
printf("链接前a是%s b是%s\n",a,b);
strcat(a,b);
printf("链接后a是%s b是%s",a,b);
}
void testStrcatArr()
{
char *s1="zhangsan",*s2="lisi",*s3="wangwu",*s4="zhaoliu";
char *names[]={*s1,*s2,*s3,*s4};
printf("交换前name[2]是%s,name[3]是%s\n",names[2],names[3]);
char *temp;
temp=names[2];
names[2]=names[3];
names[3]=temp;
printf("交换后name[2]是%s,name[3]是%s",names[2],names[3]);
}
void testSaa()
{
struct student stu1={1,"范冰冰",'N',26};
struct student stu2={2,"赵薇",'N',55};
struct student stu3={3,"林心如",'N',45};
struct student stu4={4,"成龙",'M',38};
struct student stu5={5,"李连杰",'M',34};
struct student stu6={6,"吴京",'M',35};
printf("挂科的学员如下:\n");
if(stu1.scoer<60){
printf("学号:%d\t姓名:%s\t性别:%c\t分数:%.2f\n",stu1.num,stu1.name,stu1.sex,stu1.scoer);
}
if(stu2.scoer<60){
printf("学号:%d\t姓名:%s\t性别:%c\t分数:%.2f\n",stu2.num,stu2.name,stu2.sex,stu2.scoer);
}
if(stu3.scoer<60){
printf("学号:%d\t姓名:%s\t性别:%c\t分数:%.2f\n",stu3.num,stu3.name,stu3.sex,stu3.scoer);
if(stu4.scoer<60){
printf("学号:%d\t姓名:%s\t性别:%c\t分数:%.2f\n",stu4.num,stu4.name,stu4.sex,stu4.scoer);
}
if(stu5.scoer<60){
printf("学号:%d\t姓名:%s\t性别:%c\t分数:%.2f\n",stu5.num,stu5.name,stu5.sex,stu5.scoer);
}
if(stu6.scoer<60){
printf("学号:%d\t姓名:%s\t性别:%c\t分数:%.2f\n",stu6.num,stu6.name,stu6.sex,stu6.scoer);
}
if(stu1.scoer>=60&&stu2.scoer>=60&&stu3.scoer>=60&&stu4.scoer>=60&&stu5.scoer>=60&&stu6.scoer>=60){
printf("没有挂科的学员!\n");
}
}
}