如果还有错误,请老师多多指教

更正:

byte b= (byte) (b1-b2);

char c= (char) (c1+c2-1);

void public method(){

int i=1,j;

float f1=0.1(f);float f2=123(f);

long l1=12345678(L),l2=8888888888(L);

doudle d1=2e20,b2=124;

byte b1= 1,b2= 2,b3= 129(byte范围到-128~127,所以溢出);

j=j+10(声明j时没有赋值);

i=i/10;

i=i*0.1;

char c1='a',c2=125;

float f3= (float) (f1+f2);

float f4= (float) (f1+f2*0.1);

double d=d1+i+j;

float f= (float) (d1*5*d2);

记事本作业

1.16

int a = 5;
int b = (a++) + (--a) +(++a);//a++,a先为5,后加1,a为6,--a,先减后加,减一后a为5,++a先加一,a为6,所以5+5+6=16

2.     short price=11; 
       short realPrice=(short)(price*8/10);//报错 
       System.out.println(realPrice);

如果打折后出现小数,将会自动舍去

       double price=11; 
       double realPrice=price*8/10;
       System.out.println(realPrice);

3.package java_1028;
import java.util.Scanner;
public class java_1028 {
 public static void main(String[] args) {
  Scanner scan=new Scanner(System.in);
  System.out.println("请输入5个彩票号码:");
  System.out.print(">");
  int ticketNumber=scan.nextInt();
  int g=0,s=0,b=0,q=0,w=0;
     g=ticketNumber%10;
  s=ticketNumber/10%10;
  b=ticketNumber/100%10;
  q=ticketNumber/1000%10;
  w=ticketNumber/10000;
  byte a1=(byte)g;
  byte a2=(byte)s;
  byte a3=(byte)b;
  byte a4=(byte)q;
  byte a5=(byte)w;
  System.out.println(a1+" "+a2+" "+a3+" "+a4+" "+a5);
  System.out.println(a1+a2+a3-a4+a5);
  System.out.println(a1*a2*a3*a4*a5);
  
 }
}

转载于:https://my.oschina.net/u/3716995/blog/1557762

写入单向链表到文件可以使用 fwrite() 函数,读取单向链表可以使用 fread() 函数。 写入单向链表到文件的步骤如下: 1. 打开文件,使用 fopen() 函数。 2. 遍历链表,将链表中的数据写入文件,使用 fwrite() 函数。 3. 关闭文件,使用 fclose() 函数。 例如,如果要将链表结构体 Node 写入文件,可以按照以下方式进行: ```c #include <stdio.h> // 定义链表结构体 typedef struct Node { int data; struct Node* next; } Node; // 写入链表到文件 void writeListToFile(Node* head) { FILE* fp = fopen("list.txt", "wb"); if (fp == NULL) { printf("文件打开失败\n"); return; } // 遍历链表,将链表中的数据写入文件 Node* p = head; while (p != NULL) { fwrite(p, sizeof(Node), 1, fp); p = p->next; } fclose(fp); } // 从文件中读取链表 Node* readListFromFile() { FILE* fp = fopen("list.txt", "rb"); if (fp == NULL) { printf("文件打开失败\n"); return NULL; } Node* head = NULL; Node* tail = NULL; // 从文件中读取链表结点,并添加到链表中 Node* node = (Node*)malloc(sizeof(Node)); while (fread(node, sizeof(Node), 1, fp) == 1) { node->next = NULL; if (head == NULL) { head = tail = node; } else { tail->next = node; tail = node; } node = (Node*)malloc(sizeof(Node)); } fclose(fp); return head; } ``` 注意,这里的写入和读取都是二进制方式,所以需要使用 "wb" 和 "rb" 方式打开文件。同时,需要注意写入和读取的顺序和方式,保证链表的正确性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值