❶ c语言,定义一种结构类型,能实现一个人的姓名,年龄,身高,体重信息
代码:
#include<stdio.h>
structpeople{
charname[10];
intage;
inthigh;//单位cm
floatweight;//单位kg
}p;
intmain(){
printf("请输入您的姓名、年龄、身高cm、体重kg(空格分开): ");
scanf("%s%d%d%f",&p.name,&p.age,&p.high,&p.weight);
printf("您的个人信息:姓名:%s,年龄:%d岁,身高:%dcm,体重:%0.2fkg ",p.name,p.age,p.high,p.weight);
return0;
}
运行:
❷ 如何用C语言编写自己的姓名和学号
用字符串保存就可以了
比如
intmain()
{
char*name="张三";
char*no="123456";
printf("姓名:%s 学号:%s ",name,no);
return0;
}
❸ 求C语言做通讯录管理系统,系统功能有:输入、删除、修改、查询和输出联系人信息功能,请附上简要解释
网络知道里一堆的相同问题,是不是学校的题库都来源于同一个服务器?
❹ 如何编写C语言程序使得输入编号就可以显示其他的个人信息
1、写一个结构体数组用来记录信息
这里我写了一个可以存储一个人的姓名、电话、邮箱的结构体。
structnote{
charname[100];
charphone[100];
charmail[100];
}people[1000];
2、用文件储存更加方便
p=fopen("list.txt","r");
if(p==NULL)
{
fclose(p);
p=fopen("list.txt","w");
fclose(p);
}
3、写一个简单的界面(可以用死循环)
while(1)
{
n=0;
p=fopen("list.txt","r");
while(fscanf(p,"%s%s%s",people[n].name,people[n].phone,people[n].mail)!=EOF)
n++;
fclose(p);
///--------一次循环更新一次数据
4、写一个简单的查找程序
intk;
cout<<"输入1读取,输入2输入"<<endl;
cin>>k;
if(k==1)
{
cout<<"输入信息"<<endl;
chars[100];
cin>>s;
boolok=0;
for(i=0;i<strlen(s);i++)
if(s[i]>='0'&&s[i]<='9')
ok=1;
//自动识别输入的是姓名还是电话号码
if(ok==0)
{
//cout<<"通过姓名找到联系人"<<endl;
//system("pause");
boolyou=0;
for(i=0;i<n;i++)
if(strcmp(s,people[i].name)==0)
{
you=1;
cout<<"姓名"<<people[i].name<<endl;
cout<<"电话号码"<<people[i].phone<<endl;
cout<<"邮箱"<<people[i].mail<<endl;
}
if(you==0)
cout<<"没有通过姓名找到联系人"<<endl;
}
if(ok==1)
{
//cout<<"通过电话找联系人"<<endl;
//system("pause");
boolyou=0;
for(i=0;i<n;i++)
if(strcmp(s,people[i].phone)==0)
{
you=1;
cout<<"姓名"<<people[i].name<<endl;
cout<<"电话号码"<<people[i].phone<<endl;
cout<<"邮箱"<<people[i].mail<<endl;
}
if(you==0)
cout<<"没有通过电话找到联系人"<<endl;
}
5、添加信息的代码
if(k==2)
{
p1=fopen("list.txt","a+");
charss[1000];
cout<<"请输入姓名"<<endl;
cin>>ss;
fprintf(p1,"%s ",ss);
cout<<"请输入电话"<<endl;
cin>>ss;
fprintf(p1,"%s ",ss);
cout<<"请输入邮箱"<<endl;
cin>>ss;
fprintf(p1,"%s ",ss);
fclose(p1);
}
}
最终的程序
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
usingnamespacestd;
FILE*p,*p1;
structnote{
charname[100];
charphone[100];
charmail[100];
}people[1000];
intmain()
{
intn=0,i,j;
p=fopen("list.txt","r");
if(p==NULL)
{
fclose(p);
p=fopen("list.txt","w");
fclose(p);
}
while(1)
{
n=0;
p=fopen("list.txt","r");
while(fscanf(p,"%s%s%s",people[n].name,people[n].phone,people[n].mail)!=EOF)
n++;
fclose(p);
///---------------
intk;
cout<<"输入1读取,输入2输入"<<endl;
cin>>k;
if(k==1)
{
cout<<"输入信息"<<endl;
chars[100];
cin>>s;
boolok=0;
for(i=0;i<strlen(s);i++)
if(s[i]>='0'&&s[i]<='9')
ok=1;
if(ok==0)
{
//cout<<"通过姓名找到联系人"<<endl;
//system("pause");
boolyou=0;
for(i=0;i<n;i++)
if(strcmp(s,people[i].name)==0)
{
you=1;
cout<<"姓名"<<people[i].name<<endl;
cout<<"电话号码"<<people[i].phone<<endl;
cout<<"邮箱"<<people[i].mail<<endl;
}
if(you==0)
cout<<"没有通过姓名找到联系人"<<endl;
}
if(ok==1)
{
//cout<<"通过电话找联系人"<<endl;
//system("pause");
boolyou=0;
for(i=0;i<n;i++)
if(strcmp(s,people[i].phone)==0)
{
you=1;
cout<<"姓名"<<people[i].name<<endl;
cout<<"电话号码"<<people[i].phone<<endl;
cout<<"邮箱"<<people[i].mail<<endl;
}
if(you==0)
cout<<"没有通过电话找到联系人"<<endl;
}
}
if(k==2)
{
p1=fopen("list.txt","a+");
charss[1000];
cout<<"请输入姓名"<<endl;
cin>>ss;
fprintf(p1,"%s ",ss);
cout<<"请输入电话"<<endl;
cin>>ss;
fprintf(p1,"%s ",ss);
cout<<"请输入邮箱"<<endl;
cin>>ss;
fprintf(p1,"%s ",ss);
fclose(p1);
}
}
return0;
}
❺ 用c语言编写一个通讯录,并对他进行增加,查询,删除,修改,显示记录等操作,要写出源代码并画出流程图
这个是我编的,用数组和链表两种功能实现的通讯录
基本能满足你的要求!!
代码如下:
#include "stdlib.h"
#define NEW (struct node *)malloc(sizeof(struct node))
struct student
{ char name[10],tel[11];
}a[20];
struct node
{ char name[20],tel[11];
struct node *next;
};
main()
{ struct student *jianli(),*delete(struct student *);
struct student *charu(struct student *);
void xianshi(struct student *);
struct node *create(),*delnode(struct node*,char *);
struct node *insert(struct node *,struct node *,char *);
void prlist(struct node *);
struct student *p;
struct node *head=NULL,*stu;
char s[80],name[20],q[80];
int c,w;
a:;
system("cls");
printf("\nEnter your choice\n");
printf("1.SHUZU\n2.LIANBIAO\n0.Quit\n");
gets(q);
w=atoi(q);
switch(w)
{ case 1:
do
{ do
{ printf("----------------------------------------------\n");
printf("******************Phone book******************\n");
printf("----------------------------------------------\n");
printf(" | | <1> Add a note | |\n");
printf(" | | <2> Show the list | |\n");
printf(" | | <3> Delete a note | |\n");
printf(" | | <4> Insert a note | |\n");
printf(" | | <0> Quit | |\n");
printf("----------------------------------------------\n");
printf(" Enter your choice(0-4):");
gets(s);
c=atoi(s);
}while(c<0||c>4);
system("cls");
switch(c)
{ case 1: p=jianli();break;
case 2: xianshi(p);break;
case 3: printf("\nPlease input the name to deleted\n");
p=delete(p);break;
case 4: printf("\nPlease input the new name\n");
p=charu(p);break;
}
}while(c);goto a;
case 2:
do
{ do
{printf("----------------------------------------------\n");
printf("******************Phone book******************\n");
printf("----------------------------------------------\n");
printf(" | | <1> Add a note | |\n");
printf(" | | <2> Show the list | |\n");
printf(" | | <3> Delete a note | |\n");
printf(" | | <4> Insert a note | |\n");
printf(" | | <0> Quit | |\n");
printf("----------------------------------------------\n");
printf(" Enter your choice(0-4):");
gets(s);
c=atoi(s);
}while(c<0||c>4);
system("cls");
switch(c)
{ case 1: head=create();break;
case 2: prlist(head);break;
case 3: printf("\nInput the name to deleted\n");
gets(name);
head=delnode(head,name);break;
case 4: stu=NEW;
printf("\nInput the new node\n");
printf("name:");
gets(stu->name);
printf("tel:");
gets(stu->tel);
stu->next=NULL;
printf("\nInsert position\n");
printf("name:");
gets(name);
head=insert(head,stu,name);
}
}while(c);goto a;
}
}
#include "string.h"
struct student *jianli()
{ char c1[10],c2[11];
int i=0;
printf("name:");
gets(c1);
while(strlen(c1)!=0)
{ strcpy(a[i].name,c1);
printf("tel:");
gets(c2);
strcpy(a[i].tel,c2);
i++;
printf("name:");
gets(c1);
}
return a;
}
#include "string.h"
struct student *delete(struct student *p)
{ char c1[10];
int i=0,j,l=0;
while(strlen(p[i].name)!=0)
i++;
printf("name:");
gets(c1);
for(j=0;j<=i+1;j++)
if(strcmp(c1,p[j].name)==0)
{p[j]=p[j+1];
l=j;}
while(l<i+1)
{p[l]=p[l+1];
l++;}
return p;
}
#include "string.h"
struct student *charu(struct student *p)
{ char c1[10],c2[11];
int i=0;
while(strlen(p[i].name)!=0)
i++;
printf("name:");
gets(c1);
strcpy(p[i].name,c1);
printf("tel:");
gets(c2);
strcpy(p[i].tel,c2);
return p;
}
#include "string.h"
void xianshi(struct student *p)
{ int i=0;
printf("name\ttel\n\n");
while(strlen(p[i].name)!=0)
{ printf("%s\t%s\n",p[i].name,p[i].tel);
i++;}
}
#include "stdlib.h"
#include "string.h"
#define NEW (struct node *)malloc(sizeof(struct node))
struct node *create()
{ struct node *h;
struct node *p,*q;
char name[20];
h=q=NULL;
printf("name:");
gets(name);
while(strlen(name)!=0)
{ p=NEW;
if(p==NULL)
{ printf("Allocation failure\n");
exit(0);
}
strcpy(p->name,name);
printf("tel:");
gets(p->tel);
p->next=NULL;
if(h==NULL)
h=p;
else
q->next=p;
q=p;
printf("name:");
gets(name);
}
return h;
}
struct node *insert(struct node *head,struct node *p0,char *x)
{ struct node *p,*q;
if(head==NULL)
{ head=p0;
p0->next=NULL;
}
else
{ p=head;
while(strcmp(x,p->name)!=0&&p->next!=NULL)
{ q=p;p=q->next;}
if(strcmp(x,p->name)==0)
{ if(p==head)
head=p0;
else
q->next=p0;
p0->next=p;
}
else
{ p->next=p0;
p0->next=NULL;
}
}
return head;
}
void prlist(struct node *head)
{ struct node *p;
p=head;
printf("name\ttel\n\n");
while(p!=NULL)
{ printf("%s\t%s\n",p->name,p->tel);
p=p->next;
}
}
struct node *delnode(struct node *head,char *x)
{ struct node *p,*q;
if(head==NULL)
{ printf("this is a empty list.");
return head;
}
p=head;
while(strcmp(x,p->name)!=0&&p->next!=NULL)
{ q=p;p=p->next;}
if(strcmp(x,p->name)==0)
{ if(p==head)
head=p->next;
else
q->next=p->next;
free(p);
}
else
printf("Not found.");
return head;
}
❻ 用c语言编写通讯录
自己写的,看一下
// 头文件部分
//============================
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
// 初始化数据部分
int Menu();
void Start();
void Write();
void Read();
void Search();
void Detele();
void beauty();
void Rework();
void Lock();
int Judge();
//============================
struct Student{
char name[20];
char Tel[20];
char QQ[20];
int age;
}xy[100];
char wenjian[10000];
char Number[10];
char number=0;
int GOTO;
//
int main()
{
Start();
for(;;)
{
GOTO=Menu();
if(GOTO==1)
{
for(;;)
{
Write();
int judge=Judge();
if(judge==2)
{
break;
}
}
}
if(GOTO==2)
{
for(;;)
{
Read();
system("pause");
break;
}
}
if(GOTO==3)
{
for(;;)
{
Search();
int judge=Judge();
if(judge==2)
{
break;
}
}
}
if(GOTO==4)
{
for(;;)
{
Rework();
int judge=Judge();
if(judge==2)
{
break;
}
}
}
if(GOTO==5)
{
Detele();
break;
}
if(GOTO==6)
{
beauty();
break;
}
if(GOTO==7)
{
}
if(GOTO==8)
{
printf("");
break;
}
if(GOTO==9)
{
printf("\t\t\t退出系统\n\n");
return 0;
}
if(GOTO==0)
{
printf("");
break;
}
}
// beauty();
//
// Write();
// Read();
// Search();
// Rework();
// Detele();
return 0;
}
void Write()
{
printf("\t\t\t请输入好友名字\n");
scanf("%s",&xy[number].name);
printf("\t\t\t请输入好友电话号码\n");
scanf("%s",&xy[number].Tel);
printf("\t\t\t请输入好友QQ号码\n");
scanf("%s",&xy[number].QQ);
printf("\t\t\t请输入好友年龄\n");
scanf("%d",&xy[number].age);
FILE *file;
if((file=fopen("Friend.txt","rt"))==NULL)
{
file=fopen("Friend.txt","wt");
fprintf(file,"%-20s%-20s%-20s%-20s","姓名","电话","QQ","年龄");
}
file=fopen("Friend.txt","at");
fprintf(file,"%-20s%-20s%-20s%-20d\n",xy[number].name,xy[number].Tel,xy[number].QQ,xy[number].age);
fclose(file);
number++;
Number[0]=number;
FILE * Sta;
if((Sta=fopen("number.txt","r"))=NULL)
{
Sta=fopen("number.txt","wt");
exit(1);
}
Sta=fopen("number.txt","wt");
fprintf(Sta,"%d",Number[0]);
fclose(Sta);
}
void Read()
{
printf("\t\t\t您通讯录中一共有%d位好友\n",Number[0]);
FILE* read;
if((read=fopen("Friend.txt","r"))=NULL)
{
printf("\t\t\t您通讯中当前没有好友,请返回添加\n");
}
read=fopen("Friend.txt","rt");
printf("%-20s%-20s%-20s%-20s\n","姓名","电话 ","QQ","年龄");
for(int i=0;i<number;i++)
{
fscanf(read,"%s%s%s%d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,&xy[i].age);
printf("%-20s%-20s%-20s%-20d\n",xy[i].name,xy[i].Tel,xy[i].QQ,xy[i].age);
}
/* fread(wenjian,10000,1,read);
for(int i=0;i<number*80+80;i++)
{
printf("%c",wenjian[i]);
}
printf("\n");
*/
fclose(read);
}
void beauty()
{
int d;
do{
printf("choose");
scanf("%d",&d);
}while(d<1&&d>5);
if(d==1)
{
system("color 27");
printf("===1===");
}
if(d==2)
{
system("color 37");
printf("===2===");
}
if(d==3)
{
system("color 47");
printf("===3===");
}
if(d==4)
{
system("color 57");
printf("===4===");
}
if(d==5)
{
system("color 67");
printf("===5===");
}
}
void Start()
{
FILE* Start;
if((Start=fopen("number.txt","r"))==NULL)
{
Start=fopen("number.txt","w");
number=0;
Number[0]=number;
fscanf(Start,"%d",&Number[0]);
printf("\t\t\t您的通讯录中还没有任何好友,赶快添加吧.此次操作需要重新运行程序。\n");
exit(1);
}
Start=fopen("number.txt","r");
fscanf(Start,"%d",&Number[0]);
number=Number[0];
fclose(Start);
}
void Search()
{
int change=0;
char Searchname[20];
printf("\t\t\t输入要查找的好友的名字\n\n");
scanf("%s",&Searchname);
fflush(stdin);
printf("\t\t\t您要查找的好友是 %s \n\n",Searchname);
FILE *Search;
Search=fopen("Friend.txt","rt");
for(int i=0;i<=number;i++)
{
fscanf(Search,"%s%s%s%d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,&xy[i].age);
if(strcmp(xy[i].name,Searchname)==0)
{
printf("\t\t\t下面是该好友的信息:\n\n");
printf("%-20s%-20s%-20s%-20s\n","姓名","电话 ","QQ","年龄");
printf("%-20s%-20s%-20s%-20d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,xy[i].age);
change=1;
}
fclose(Search);
}
if(change==0)
{
printf("\t\t\t您要查找的好友不存在,请返回菜单添加。\n");
}
}
void Rework()
{
char Rework[20];
printf("\t\t\t输入要修改的好友的名字\n\n");
scanf("%s",&Rework);
printf("\t\t\t您要修改 %s 的信息\n\n",Rework);
int Change=0;
FILE *Search;
Search=fopen("Friend.txt","rt");
for(int i=0;i<=number;i++)
{
fscanf(Search,"%s%s%s%d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,&xy[i].age);
if(strcmp(xy[i].name,Rework)==0)
{
printf("\t\t\t下面是该好友的信息:\n\n");
printf("%-20s%-20s%-20s%-20s\n","姓名","电话 ","QQ","年龄");
Change=1;
int Choose;
printf("%-20s%-20s%-20s%-20d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,xy[i].age);
//---------------------------------------------------------------------
do
{
printf("\t\t\tchoose\t\t\t1-----3");
scanf("%d",&Choose);
}while(Choose>3||Choose<1);
if(Choose==1){
printf("\t\t\t请输入好友电话号码\n");
scanf("%s",&xy[i].Tel);
}
if(Choose==2)
{
printf("\t\t\t请输入好友QQ号码\n");
scanf("%s",&xy[i].QQ);
}
if(Choose==3)
{
printf("\t\t\t请输入好友年龄\n");
scanf("%d",&xy[i].age);
}
Search=fopen("Friend.txt","wt");
for(int sta=0;sta<i;sta++)
{
fprintf(Search,"%-20s%-20s%-20s%-20d\n",xy[sta].name,xy[sta].Tel,xy[sta].QQ,xy[sta].age);
}
if(sta==i)
{
fprintf(Search,"%-20s%-20s%-20s%-20d\n",xy[i].name,xy[i].Tel,xy[i].QQ,xy[i].age);
i++;
}
for(i;i<=number;i++)
{
fprintf(Search,"%-20s%-20s%-20s%-20d\n",xy[i].name,xy[i].Tel,xy[i].QQ,xy[i].age);
}
printf("\t\t\t修改后的信息为:\n\n");
Read();
}
fclose(Search);
}
if(Change==0)
{
printf("\t\t\t您要查找的好友不存在,请返回菜单添加。\n");
}
}
void Detele()
{
int change=0;
char delete_friend[20];
printf("\t\t\t输入要删除的好友的名字\n\n");
scanf("%s",&delete_friend);
fflush(stdin);
printf("\t\t\t您要删除的好友是 %s \n\n",delete_friend);
FILE *DeleteF;
DeleteF=fopen("Friend.txt","rt");
for(int i=0;i<=number;i++)
{
fscanf(DeleteF,"%s%s%s%d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,&xy[i].age);
if(strcmp(xy[i].name,delete_friend)==0)
{
printf("\t\t\t下面是该好友的信息:\n\n");
printf("%-20s%-20s%-20s%-20s\n","姓名","电话 ","QQ","年龄");
printf("%-20s%-20s%-20s%-20d\n",&xy[i].name,&xy[i].Tel,&xy[i].QQ,xy[i].age);
change=1;
DeleteF=fopen("Friend.txt","wt");
for(int st=0;st<i;st++)
{
fprintf(DeleteF,"%-20s%-20s%-20s%-20d\n",xy[st].name,xy[st].Tel,xy[st].QQ,xy[st].age);
}
i++;
for(i;i<=number;i++)
{
printf("%-20s%-20s%-20s%-20d\n",xy[i].name,xy[i].Tel,xy[i].QQ,xy[i].age);
fprintf(DeleteF,"%-20s%-20s%-20s%-20d\n",xy[i].name,xy[i].Tel,xy[i].QQ,xy[i].age);
}
}
//--------------------------------------------------------------------------------
if(change==1)
{
printf("\t\t\t删除后的通讯录信息为:\n\n");
number--;
Number[0]=number;
FILE * St;
if((St=fopen("number.txt","r"))=NULL)
{
St=fopen("number.txt","wt");
exit(1);
}
St=fopen("number.txt","wt");
fprintf(St,"%d",Number[0]);
fclose(St);
fclose(DeleteF);
Start();
Read();
}
}
if(change==0)
{
printf("\t\t\t您要删除的好友不存在。\n");
}
}
void Lock()
{
}
int Menu()
{
printf("\t\t*****欢迎进入通讯管理界面*****\n\n");
printf("\t\t\t1.添加我的好友\n");
printf("\t\t\t2.显示所有好友\n");
printf("\t\t\t3.查找我的好友\n");
printf("\t\t\t4.修改好友信息\n");
printf("\t\t\t5.删除我的好友\n");
printf("\t\t\t6.设置背景颜色\n");
printf("\t\t\t7.设置管理密码\n");
printf("\t\t\t8.使用注意事项\n");
printf("\t\t\t9.退出通讯系统\n");
printf("\t\t\t0.作者想说的话\n");
printf("\t\t******************************\n\n");
do{
printf("\t\t\t请输入你的选择:\n\n");
scanf("%d",&GOTO);
}while(GOTO>9||GOTO<1);
return GOTO;
}
int Judge()
{
char JUDGE;
do
{
printf("\t\t\t是否继续当前操作\n\n Y(yes) / N(no)\n");
printf("\t\t\t输入你的选择\n");
JUDGE=getch();
if(JUDGE=='y'||JUDGE=='Y')
{
return 1;
}
if(JUDGE=='n'||JUDGE=='N')
{
return 2;
}
}while(JUDGE!='y'||JUDGE!='n');
}
❼ c语言学生成绩管理系统的删除学生信息怎么写,求代码
删除学生信息你可以用一条其他信息来覆盖这条要删除的信息
这样你的信息就不存在了 也就是删除了
有疑问欢迎探讨
❽ 用c语言写职工信息系统.我写的没法修改信息!谁能帮我改一下这个子函数
子表 ( MADE IN 127 ) ***/
/*** ! 在程序运行过程中不要切换窗口,否则,会出错 . ***/
#include<graphics.h>
#include<math.h>
#include<time.h>
#define STEP 6.283183/60
#define PI 3.141592
#define X 307
#define Y 150 /*** 中心坐标 ***/
#define R 100
#define R_OUT (R+4) /*** 内外半径 ***/
#define R_S (R-20)
#define R_M (R-35)
#define R_H (R-50) /*** 各指针半径 ***/
#define MIN 60 /*** 设定延时 (分钟) ***/
#define C_I 9
int HH=0,MM=0;
main()
{
int gd=DETECT,gm,second,record_s,minite,record_m,hour,i,pc=60;
time_t t; float temp; char ch='#';
int int_M=MIN; pc=(MIN-int_M)*60;
initgraph (&gd,&gm,""); setbkcolor (0);
/*** 外观设计 ***/
circle (X,Y,R); setfillstyle (1,2); floodfill (X,Y,15);
circle (X,Y,R_OUT); setfillstyle (1,8); floodfill (X+R_OUT-1,Y,15);
rectangle (X-2,Y-R+8-4,X+2,Y-R+8+4);
rectangle (X-2,Y+R-8-4,X+2,Y+R-8+4);
rectangle (X-R+8-4,Y-2,X-R+8+4,Y+2);
rectangle (X+R-8-4,Y-2,X+R-8+4,Y+2);
for (i=1;i<=60;i++)
if (i!=15&&i!=30&&i!=45&&i!=60)
if (i%5!=0) circle (X+(R-10)*cos(i*STEP),Y+(R-10)*sin(i*STEP),1);
else circle (X+(R-10)*cos(i*STEP),Y+(R-10)*sin(i*STEP),2);
rectangle (X+R_OUT,Y-6,X+R_OUT+6,Y+6);
setfillstyle (1,8); floodfill (X+R_OUT+3,Y,15);
temp=R_OUT*0.866;
line (X-R_OUT/2-5,Y-temp+2,X-R_OUT/2,Y-temp-30);
line (X-R_OUT/2+5,Y-temp-2,X-R_OUT/2+5,Y-temp-30);
line (X+R_OUT/2-5,Y-temp-2,X+R_OUT/2-5,Y-temp-30);
line (X+R_OUT/2+5,Y-temp+2,X+R_OUT/2,Y-temp-30);
line (X-R_OUT/2,Y-temp-30,X-R_OUT/2+5,Y-temp-30);
line (X+R_OUT/2-5,Y-temp-30,X+R_OUT/2,Y-temp-30);
line (X-R_OUT/2+5,Y-temp-25,X+R_OUT/2-5,Y-temp-25);
line (X-R_OUT/2+5,Y-temp-22,X+R_OUT/2-5,Y-temp-22);
floodfill (X-R_OUT/2-2,Y-temp,15);
floodfill (X+R_OUT/2+2,Y-temp,15);
floodfill (X,Y-R_OUT-10,15);
line (X-R_OUT/2-5,Y+temp-2,X-R_OUT/2,Y+temp+30);
line (X-R_OUT/2+5,Y+temp+2,X-R_OUT/2+5,Y+temp+30);
line (X+R_OUT/2-5,Y+temp+2,X+R_OUT/2-5,Y+temp+30);
line (X+R_OUT/2+5,Y+temp-2,X+R_OUT/2,Y+temp+30);
line (X-R_OUT/2,Y+temp+30,X-R_OUT/2+5,Y+temp+30);
line (X+R_OUT/2-5,Y+temp+30,X+R_OUT/2,Y+temp+30);
line (X-R_OUT/2+5,Y+temp+25,X+R_OUT/2-5,Y+temp+25);
line (X-R_OUT/2+5,Y+temp+22,X+R_OUT/2-5,Y+temp+22);
floodfill (X-R_OUT/2-2,Y+temp,15);
floodfill (X+R_OUT/2+2,Y+temp,15);
floodfill (X,Y+R_OUT+10,15);
for (i=1;i<=MIN*60+1;i++) /*** 该循环严格一秒一次 ( 捕捉系统时间 ) ***/
{
setcolor (15);
circle (X,Y,5); circle (X,Y,2); setfillstyle (1,0); floodfill (X,Y,15);
settextstyle (2,0,0); setcolor (8); outtextxy (X-13,Y-52,"FIYTA");
outtextxy (X-30,Y+35,"MADE IN 127"); setcolor (2);
time (&t); /*** 获取系统时间 ***/
hour=(ctime(&t)[11]-'0')*10+(ctime(&t)[12]-'0');
minite=(ctime(&t)[14]-'0')*10+(ctime(&t)[15]-'0');
second=(ctime(&t)[17]-'0')*10+(ctime(&t)[18]-'0');
if (ch==C_I)
hour=(hour+HH)%24; minite=(minite+MM)%60;
window (22,22,80,22); printf (" The current time is ");
if (hour<10) printf ("0"); printf ("%d : ",hour);
if (minite<10) printf ("0"); printf ("%d : ",minite);
if (second<10) printf ("0"); printf ("%d",second);
window (35,20,80,20);
printf (" "); if (int_M<10) printf ("0"); printf ("%d : ",int_M);
if (pc<10) printf ("0"); printf ("%d ",pc);
record_m=minite;
hour=10*hour+minite/6-30;
minite=2*minite+second/30-30;
second-=15; record_s=second;
setcolor (0); /*** 写指针 ***/
line (X+7*cos(PI+hour*STEP/2),Y+7*sin(PI+hour*STEP/2),X+R_H*cos(hour*STEP/2),Y+R_H*sin(hour*STEP/2));
setcolor (1);
line (X+13*cos(PI+minite*STEP/2),Y+13*sin(PI+minite*STEP/2),X+R_M*cos(minite*STEP/2),Y+R_M*sin(minite*STEP/2));
setcolor (4);
line (X+20*cos(PI+second*STEP),Y+20*sin(PI+second*STEP),X+R_S*cos(second*STEP),Y+R_S*sin(second*STEP)); record_s=second;
ch='#';
while (second==record_s) /*** 此循环用来 " 监视 " 系统秒针的变化 ***/
{
time (&t); second=(ctime(&t)[17]-'0')*10+(ctime(&t)[18]-'0')-15;
if (bioskey(1)&&(ch=getch())==C_I||ch==27)
{
if (ch==27)
window (22,22,80,22); printf (" PLS enter the time : ");
window (48,22,80,22);
while (!bioskey(1))
scanf ("%d:%d:%d",&HH,&MM);
if (HH<=23&&HH>=0&&MM>=0&&MM<=59) break; else
}
}
setcolor (2); /*** 覆盖指针 ( 由秒控制 ) ***/
if ((record_m*60+60+second+15)%360==0||ch==C_I)
line (X+7*cos(PI+hour*STEP/2),Y+7*sin(PI+hour*STEP/2),X+R_H*cos(hour*STEP/2),Y+R_H*sin(hour*STEP/2));
if ((second+15)%30==0||ch==C_I)
line (X+13*cos(PI+minite*STEP/2),Y+13*sin(PI+minite*STEP/2),X+R_M*cos(minite*STEP/2),Y+R_M*sin(minite*STEP/2));
if (i!=60*MIN+1||ch==C_I)
line (X+20*cos(PI+record_s*STEP),Y+20*sin(PI+record_s*STEP),X+R_S*cos(record_s*STEP),Y+R_S*sin(record_s*STEP));
if (pc==0&&int_M!=0) pc=60; pc--; if (pc==59) int_M--;
}
window (20,22,80,22);
printf (" The watch time out! Press any key ... "); getch ();
closegraph ();
}
❾ c语言个人信息管理
c语言个人信息帮实现
❿ c语言学生信息管理系统代码
代码如下:
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
typedef struct examinee //考生信息结构
{ char examno[20]; //准考证号
char name[10]; //姓名
char sex[4]; //性别
short age; //年龄
char examtype[10]; //报考科目
}ElemType;
typedef struct Node //定义链表结点
{
ElemType data; //数据域
struct Node *next; //指针域
}Node,*List,*position;
List make_empty( List L ); //创建一个带头结点的空表
int is_empty( List L ); //测试链表是否是空表
int is_last( position p, List L ); //测试当前位置是否是表尾
position make_node( position p,int n ); //创建结点并输入考生信息
void put_information( position p ); //是否输出该考生信息
void put_name_information( List L ); //输出姓名为xx的考生信息
int put_pos_information( position p ); //输出该地址考生信息
void link_to_tail( List L, position p ); //将结点连接到表尾
int ciculation_make(); //循环创建考生信息
int judge_put_all(); //是否输出所有考生信息
void put_all(List L); //输出所有考生信息。
position find( List L ); //查找第一个姓名为xx的元素并返回位置
position find_previous( List L ); //查找第一个姓名为xx的元素并返回该元素直接前驱的位置
//int judge_delete_val(); //询问是否删除考生数据
int delete_val( List L ); //删除指定考生信息并输出其信息
void menu(List L); //菜单函数
List L;
//position p;
int
main( void )
{
List L = NULL; //定义头结点指针
position p = NULL; //定义表工作指针
L = make_empty( L ); //创建空表
printf(" ★★考生报名管理程序★★
----------------------------------------
");
menu(L);
return 0;
}
//创建一个带头结点的空表
List
make_empty( List L)
{
L = ( List ) malloc (sizeof( Node ));
if(NULL == L)
{
printf("内存分配失败");
exit( 1 );
}
L->next = NULL;
//printf("空表创建成功。
");
return L;
}
//创建结点并输入考生信息
position
make_node( position p ,int n)
{
if(n) //n为1是创建结点并输入,n为0是修改
{
p = ( position ) malloc ( sizeof ( Node ));
p->next = NULL ;
}
printf("请输入考生准考证号:");
gets(p->data.examno);
printf("请输入考生姓名:");
gets(p->data.name);
do
{
printf("请输入考生性别,只能输入“男”或者“女”:");
gets(p->data.sex);
}
while( 0 != strcmp( p->data.sex, "男" ) && 0 != strcmp( p->data.sex, "女" )); //判断性别是否有误
printf("请输入考生年龄:");
scanf("%hd",&p->data.age);
getchar(); //如果把这句删掉,就“无法执行”下面的报考类别
/*下面的do while用来判断报考类别是否输入有误*/
do
{
printf("请输入报考类别,只能输入“数学”或“英语”或者“数据结构”:");
gets(p->data.examtype);
}
while( 0 != strcmp( "英语", p->data.examtype ) && 0 != strcmp( "数学", p->data.examtype ) && 0 != strcmp( "数据结构", p->data.examtype ));
if(n)
{
printf("报名成功
");
}
else
{
printf("修改成功
");
}
return p;
}
//前插法;
void
link_to_tail( List L, position p)
{
p->next = L->next;
L->next = p;
}
//查找第一个姓名为xx的元素并返回位置
position
find( List L )
{
position p = L->next;
char name[10];
printf("请输入你要查找的考生姓名:");
gets(name);
while( p != NULL && 0 != strcmp( p->data.name , name))
{
p=p->next;
}
return p;
}
//测试链表是否是空表
int
is_empty( List L )
{
return L->next == NULL;
}
//测试当前位置是否是表尾
int
is_last( position p, List L )
{
return p->next == NULL;
}
//输出姓名为xx的考生信息
void
put_name_information( List L )
{
position p = find(L);
if(p!=NULL)
{
printf("您要查找的考生信息:
");
printf("准考证号:%s 姓名:%s 性别:%s 年龄:%hd 报考科目:%s
",p->data.examno,p->data.name,p->data.sex,p->data.age,p->data.examtype);
}
else
{
printf("没有您要找的学生。
");
}
}
//循环创建考生信息
int
ciculation_make()
{
int n = 2;
do
{
printf("是否继续创建考生信息?是请输入“1”,不是请输入“0”:");
scanf("%d",&n);
getchar();
}
while( n != 0 && n != 1);
return n;
}
//是否输出考生信息
void
put_information( position p )
{
int n=2;
do
{
printf("是否输出该考生信息?是请输入“1”,不是请输入“0”:");
scanf("%d",&n);
getchar();
}
while( n != 0 && n != 1);
if(n)
{
printf("准考证号:%s 姓名:%s 性别:%s 年龄:%hd 报考科目:%s
",p->data.examno,p->data.name,p->data.sex,p->data.age,p->data.examtype);
}
}
//是否输出所有考生信息
int
judge_put_all()
{
int n = 2;
do
{
printf("是否输出所有考生信息?是请输入“1”,不是请输入“0”:");
scanf("%d",&n);
getchar();
}
while( n != 0 && n != 1);
return n;
}
//输出所有考生信息
void
put_all(List L)
{
if(L->next == NULL)
{
printf("现无考生报名!
");
}
else
{
position p=L->next;
while( p != NULL )
{
printf("准考证号:%s 姓名:%s 性别:%s 年龄:%hd 报考科目:%s
",p->data.examno,p->data.name,p->data.sex,p->data.age,p->data.examtype);
p=p->next;
}
}
//getchar();
}
//询问是否删除考生数据
int
judge_delete_val()
{
int n = 2;
do
{
printf("是否要删除某个考生数据?是请输入“1”,不是输入“0”:");
scanf("%d",&n);
getchar();
}
while( n != 0 && n != 1);
return n;
}
//查找第一个姓名为xx的元素并返回其直接前驱的位置
position
find_previous( List L )
{
position q = L;
position p = L->next;
char name[10];
printf("请输入你要查找的考生姓名:");
gets(name);
while( p != NULL && 0 != strcmp( p->data.name , name))
{
q=p;
p=p->next;
}
if( p != NULL )
{
return q;
}
else
return p;
}
//删除指定考生信息并输出其信息
int
delete_val(List L)
{
int n=2;
position q=NULL;
position p=find_previous( L ); //返回考生信息地址
if( NULL == p )
{
printf("你要删除的考生不存在
");
return 0;
}
else
{
q = p->next;
p->next = q->next;
printf("删除成功。
删除的考生信息为:
");
printf("准考证号:%s 姓名:%s 性别:%s 年龄:%hd 报考科目:%s
",q->data.examno,q->data.name,q->data.sex,q->data.age,q->data.examtype);
free(q);
return 1;
}
}
//输出该地址考试信息
int
put_pos_information( position p )
{
if(p != NULL )
{
printf("准考证号:%s 姓名:%s 性别:%s 年龄:%hd 报考科目:%s
",p->data.examno,p->data.name,p->data.sex,p->data.age,p->data.examtype);
return 1;
}
else
{
printf("没有您要查找的学生。");
return 0;
}
}
//菜单函数
void
menu(List L)
{
printf(" a. 考生报名入口
");
printf(" b. 查询考生信息
");
printf(" c. 修改考生信息
");
printf(" d. 删除考生信息
");
printf(" e. 全部考生信息
");
printf(" f. 程序作者信息
");
printf(" g. 退出程序
");
char n='h';
while(n != 'g')
{
do //确定正确输入
{
printf("请通过字母序号选择功能:");
n = getchar();
getchar();
putchar('
');
if( n < 'a' || n > 'g')
{
printf("错误的字母序号。
");
}
}
while( n < 'a' || n > 'g' );
switch (n)
{
case 'a':
{
printf("请输入报名考生信息:
");
position p = make_node( p, 1 ); //创建新结点
link_to_tail( L, p ); //将新结点连接到表上
put_information( p ); //是否输出该考生信息
putchar('
');
}
break;
case 'b':
{
put_name_information( L );
putchar('
');
}
break;
case 'c':
{
int n=0;
position p = NULL;
printf("您正在进行修改操作。
");
p = find(L);
n = put_pos_information( p );
if(n)
{
make_node( p , 0 );
put_information( p ); //是否输出该考生信息
}
putchar('
');
}
break;
case 'd':
{
printf("您正在进行删除操作。
");
delete_val( L );
putchar('
');
}
break;
case 'e':
{
put_all( L );
putchar('
');
}
break;
case 'f':
{
printf(" 修改日期 版本号 修改人 修改内容
");
printf(" --------------------------------------------------------
");
printf(" 2018.6.19 v2.0 陈百川 增加主菜单
");
printf(" 2018.6.23 v3.0 陈百川 增加生成文件功能
");
printf(" 该版本号为v2.0
");
putchar('
');
}
break;
default:
break;
}
}
printf(" 感谢本次使用,祝您生活愉快。");
getch();
}
(10)c语言中修改个人信息的代码扩展阅读:
C语言是一门通用计算机编程语言,广泛应用于底层开发。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。
尽管C语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上进行编译,甚至包含一些嵌入式处理器(单片机或称MCU)以及超级电脑等作业平台。
二十世纪八十年代,为了避免各开发厂商用的C语言语法产生差异,由美国国家标准局为C语言制定了一套完整的美国国家标准语法,称为ANSI C,作为C语言最初的标准。[1]目前2011年12月8日,国际标准化组织(ISO)和国际电工委员会(IEC)发布的C11标准是C语言的第三个官方标准,也是C语言的最新标准,该标准更好的支持了汉字函数名和汉字标识符,一定程度上实现了汉字编程。
C语言是一门面向过程的计算机编程语言,与C++,Java等面向对象的编程语言有所不同。
其编译器主要有Clang、GCC、WIN-TC、SUBLIME、MSVC、Turbo C等。
参考资料:
网络——C语言