繁花落尽丶杰
发表于 2013-5-1 21:32:11
{:5_96:}坚持坚持
喜欢散步
发表于 2013-5-1 22:00:55
啊, 楼主加油哇, 我也是自学的。
冰点雨
发表于 2013-5-2 00:57:27
#include <stdio.h>
#include <string.h>
void main()
{
struct student
{
long int num;
char name ;
char scx;
char sex;
float score;
}stu_1, *p;
p=&stu_1;
stu_1.num=89101;
strcpy(stu_1.name,"LiLin");
(*p).sex='M';
p->score=89.5;
printf("\nNo:%d\nname:%s\nsex:%c\nscore:%f\n",
(*p).num,p->name,stu_1.sex,p->score);
}
冰点雨
发表于 2013-5-3 02:08:33
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define LEN sizeof(struct student)// student结构的大小
//struct student *creat(); //创建链表
void print(struct student *head); //打印链表
struct student
{
int num;
float score;
struct student *next;
}*creat();
int n; //全局变量,用来记录存放了多少数据。
void main()
{
struct student *stu;
stu = creat();
print( stu );
printf("\n\n");
system("pause");
}
struct student *creat()
{
struct student *head;
struct student *p1, *p2;
p1 = p2 = (struct student *)malloc(LEN);// LEN是student结构的大小
printf("%d\n",LEN);
printf("Please enter the num :");
scanf("%d", &p1->num);
printf("Please enter the score :");
scanf("%f", &p1->score);
head = NULL;
n = 0;
while( 0 != p1->num )
{
n++;
if( 1 == n )
{
head = p1;
}
else
{
p2->next = p1;
}
p2 = p1;
p1 = (struct student *)malloc(LEN);
printf("\nPlease enter the num :");
scanf("%d", &p1->num);
printf("Please enter the score :");
scanf("%f", &p1->score);
}
p2->next = NULL;
return head;
}
void print(struct student *head)
{
struct student *p;
printf("\nThere are %d records!\n\n", n);
p = head;
if( NULL != head )
{
do
{
printf("学号为 %d 的成绩是: %f\n", p->num, p->score);
p = p->next;
}while( NULL != p );
}
}
冰点雨
发表于 2013-5-4 07:42:53
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *fp;
char ch, filename;
printf("Please input the filename you want to write: ");
scanf("%s", filename);
if( !(fp = fopen(filename, "r")))
{
printf("Cannot open the file!\n");
exit(0); // 终止程序
}
while( ch != EOF ) // ctrl + z
{
ch = fgetc(fp);
putchar(ch);
}
fclose(fp);
}
feitianqu
发表于 2013-5-4 10:06:25
不可能吧我猜你不懂指针结构体
冰点雨
发表于 2013-5-4 14:26:04
feitianqu 发表于 2013-5-4 10:06 static/image/common/back.gif
不可能吧我猜你不懂指针结构体
{:5_97:} 指针 完全掌握那是不可能滴 ; 但是理解那几种形式还是做到了 结构体嘛 其实链表 就是结构体加指针;
我们感觉难是因为问题复杂 化了 返璞归真, 拆开来看问题就简单多了;看来看去 其实就是组合;
变量,常量赋值 ,模块化 顺寻结构 一路来再到指针 结构体··;
好比指针; 如果不看星号他就是 一个变量; 其实看视频别心浮气躁; 像指针我每个 看5-10遍 ; 一天看12小时··功到自然成···
冰点雨
发表于 2013-5-5 07:22:46
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define LEN sizeof(struct student)// student结构的大小
struct student *creat(); //创建链表
struct student *del( struct student *head, int num);//del函数用于删除结点, *head即链表
//的头指针, num是要删除的结点num。
void print(struct student *head); //打印链表
struct student
{
int num;
float score;
struct student *next;
};
int n; //全局变量,用来记录存放了多少数据。
void main()
{
struct student *stu, *p;
int n;
stu = creat();
p = stu;
print( p );
printf("Please enter the num to delete: ");
scanf("%d", &n);
print( del(p, n) );
printf("\n\n");
system("pause");
}
struct student *creat()
{
struct student *head;
struct student *p1, *p2;
p1 = p2 = (struct student *)malloc(LEN);// LEN是student结构的大小
printf("Please enter the num :");
scanf("%d", &p1->num);
printf("Please enter the score :");
scanf("%f", &p1->score);
head = NULL;
n = 0;
while( p1->num )
{
n++;
if( 1 == n )
{
head = p1;
}
else
{
p2->next = p1;
}
p2 = p1;
p1 = (struct student *)malloc(LEN);
printf("\nPlease enter the num :");
scanf("%d", &p1->num);
printf("Please enter the score :");
scanf("%f", &p1->score);
}
p2->next = NULL;
return head;
}
void print(struct student *head)
{
struct student *p;
printf("\nThere are %d records!\n\n", n);
p = head;
if( head )
{
do
{
printf("学号为 %d 的成绩是: %f\n", p->num, p->score);
p = p->next;
}while( p );
}
}
struct student *del( struct student *head, int num)
{
struct student *p1, *p2;
if( NULL == head )
{
printf("\nThis list is null!\n");
goto end;
}
p1 = head;
while( p1->num != num && p1->next != NULL)
{
p2 = p1;
p1 = p1->next;
}
if( num == p1->num )
{
if( p1 == head )
{
head = p1->next;
}
else
{
p2->next = p1->next;
}
printf("Delete No: %d succeed!\n", num);
n = n-1;
}
else
{
printf("%d not been found!\n", num);
}
end:
return head;
}
福禄娃娃
发表于 2013-5-5 08:47:21
楼主加油,鱼C加油!我们都看好你哦!
修缘
发表于 2013-5-5 08:53:46
楼主要是初中文凭那里要加油了,如果你没有充分的想像力,那你学的也是白干
juezezaiyuc
发表于 2013-5-5 09:23:07
激动人心,无法言表!
feitianqu
发表于 2013-5-5 09:56:33
fire8223069 发表于 2013-5-5 08:47 static/image/common/back.gif
楼主加油,鱼C加油!我们都看好你哦!
强烈支持楼主ing…我太笨了我学了几个月了也就这样
helloworld01
发表于 2013-5-5 10:22:30
我只是路过打酱油的。
姑苏落叶
发表于 2013-5-5 22:44:41
强烈支持楼主ing……
姑苏落叶
发表于 2013-5-5 22:45:59
强烈支持楼主ing……
冰点雨
发表于 2013-5-6 00:45:28
栈 的原理 先进 后出 指令PUSH pop
冰点雨
发表于 2013-5-7 02:31:24
mov ax,236
mov cx,122
s :add ax,ax
loop s
冰点雨
发表于 2013-5-8 03:24:38
assume cs:code
code segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
mov bx,0
mov ax,0
mov cx,8
s:add ax,cx:
add bx,2
loop s
mov ax,4c00h
int 21h
code ends
end
wdfwdf2727
发表于 2013-5-8 21:52:05
励志贴啊,好贴·
冰点雨
发表于 2013-5-9 01:43:48
codesg segment
start :mov ax,datasg
mov si,0
mov cx,8
s: mov ax,0
mov 16,ax
add si,2
loop s
mov ax,4c00h
int 21h
codesg ends
end start