写一个读入一个字符串,把它顺序存入一个双向链表,并按逆序输出的程序 (数据结构c语言)

写一个读入一个字符串,把它顺序存入一个双向链表,并按逆序输出的程序 (数据结构c语言),第1张

#include "stdioh"

struct node

{

struct node front;

char c;

struct node next;

};

struct node input(struct node top);

int main(void)

{

struct node T,top=&T,tail=&T,p=NULL;

Tfront=NULL;

Tnext=NULL;

Tc='\0';

tail=input(top);

p=tail->front;

while(p!=NULL)

{

printf("%c",p->c);

p=p->front;

}

return 0;

}

struct node input(struct node top)

{

int i=0;

struct node t;

char x;

while((x=getchar())!='\n')

{

top->c=x;

t=(struct node )malloc(sizeof(struct node));

top->next=t;

t->front=top;

t->next=NULL;

t->c='\0';

top=top->next;

}

return top;

}

你好!!

P0 = 0xFF 的结果是:

P0口: 7 6 6 4 3 2 1 0

状态: 1 1 1 1 1 1 1 1

P0 = 0xFE 的结果是:

P0口: 7 6 6 4 3 2 1 0

状态: 1 1 1 1 1 1 1 0

从端口的状态可以看到,P0 = 0xFF的时候,8个端口都可以接受低电平的输入

而 P0 = 0xFE 的时候,只有 1 到 7,7个端口都可以接受低电平的输入,这就是区别

#include <stdioh>

int write();

int read();

int main()

{

int a=0;

printf("请选择数字:1写,2读,3退出\n");

scanf("%d",&a);

if(a==1)

{

return write();

}

else if(a==2)

{

return read();

}

else

return 0;

}

int write()

{

char a[100]="kgasgdksagdasd";//可以改

FILE fp;

fp = fopen("d:\\DIYItxt", "w");

if (fp == 0)

{

printf("Can not open it");

}

else

{

fwrite(a, 100, 1, fp);

printf("已经写入啦!!!\n");

}

fclose(fp);

return 0;

}

int read()

{

FILE fp;

char a[100];

fp = fopen("d:\\DIYItxt", "r");

if(fp == 0)

{

printf("Can not open the file");

}else

{

fread(&a, 100, 1, fp);

}

fclose(fp);

printf("%s\n", a);

return 0;

}

以上就是关于写一个读入一个字符串,把它顺序存入一个双向链表,并按逆序输出的程序 (数据结构c语言)全部的内容,包括:写一个读入一个字符串,把它顺序存入一个双向链表,并按逆序输出的程序 (数据结构c语言)、51单片机为准双向口,读入前先写1,为什么有的程序是P0=0Xff,有的就是P0=0xfe、我想用VC写的两个程序对同一个文件 *** 作,一个程序写入,一个程序读取等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9586262.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存