java逻辑运算符 C语言结构体定义

复制代码
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);// !取反,!具有多个反应
}

//结构体的定义

//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;

}

相关推荐
CUMT_DJ26 分钟前
matlab计算算法的运行时间
开发语言·算法·matlab
SUPER52661 小时前
FastApi项目启动失败 got an unexpected keyword argument ‘loop_factory‘
java·服务器·前端
咕噜咕噜啦啦2 小时前
Eclipse集成开发环境的使用
java·ide·eclipse
Overboom3 小时前
[C++] --- 常用设计模式
开发语言·c++·设计模式
Univin4 小时前
C++(10.4)
开发语言·数据结构·c++
KyollBM4 小时前
每日羊题 (质数筛 + 数学 | 构造 + 位运算)
开发语言·c++·算法
光军oi5 小时前
全栈开发杂谈————关于websocket若干问题的大讨论
java·websocket·apache
weixin_419658315 小时前
Spring 的统一功能
java·后端·spring
Paul_09205 小时前
golang面经——map模块和sync.Map模块
开发语言
小许学java5 小时前
Spring AI-流式编程
java·后端·spring·sse·spring ai