1.
public static void main(String[] args) { System.out.println(true&true);//&两者均为true才true System.out.println(false|false);// | 两边都是false才是false System.out.println(true^false);//^ 相同为false,不同为true System.out.println(!false);// !取反,!具有多个反应 }
2.
//结构体的定义
//1.先声明,再定义
/*struct student
{
int num;
int C_score;
int ps_score;
float avg; //数据类型内不能赋初值
};
int main(void)
{
//定义:类型名+变量名
int c=0;
struct student Tom = {10,90,98,94.5};//可单独赋值
//struct student为类型名,Tom为变量名
c = 50;
Tom.num = 12;
Tom.C_score = 99;
Tom.ps_score = 96;
Tom.avg = 94.5; //就是变量
printf("序号:%d\n", Tom.num);
printf("c语言成绩:%d\n", Tom.C_score);
printf("PS成绩:%d\n", Tom.ps_score);
printf("平均分:%d\n", Tom.avg);
//与上面的一样
return 0;
}*/
//2.声明的同时,直接定义
/*struct student
{
int num;
int C_score;
int ps_score;
float avg;
}Terry,jem;//均为结构体变量
int main(void)
{
}*/
//3.省略结构体变量,直接定义结构体变量
struct student
{
int num;
int score[3];
float avg;
};
int main(void)
{
struct student Tom = { 10,{90,90,90},90 };
struct student Jim = { 10,90,90,90,90,};
//两者大部分相同,除非数字个数不同时
printf("序号:%d\n", Jim.num);
printf("成绩1:%d\n", Jim.score[0]);
printf("成绩2:%d\n", Jim.score[1]);
printf("成绩3:%d\n", Jim.score[2]);
printf("平均分:%f \n", Jim.avg);
return 0;
}