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;

}

相关推荐
lly2024061 小时前
Bootstrap 警告框
开发语言
2601_949146532 小时前
C语言语音通知接口接入教程:如何使用C语言直接调用语音预警API
c语言·开发语言
你撅嘴真丑2 小时前
第九章-数字三角形
算法
曹牧2 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
KYGALYX2 小时前
服务异步通信
开发语言·后端·微服务·ruby
uesowys2 小时前
Apache Spark算法开发指导-One-vs-Rest classifier
人工智能·算法·spark
zmzb01032 小时前
C++课后习题训练记录Day98
开发语言·c++
ValhallaCoder2 小时前
hot100-二叉树I
数据结构·python·算法·二叉树
董董灿是个攻城狮2 小时前
AI 视觉连载1:像素
算法
爬山算法2 小时前
Hibernate(90)如何在故障注入测试中使用Hibernate?
java·后端·hibernate