當前位置:首頁 » 編程語言 » c語言課程設計實驗設備
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言課程設計實驗設備

發布時間: 2023-08-11 23:04:08

c語言程序設計《實驗設備管理系統設計》~

下面的是我前幾天剛針對這題目做的做的:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct shebei
{
char ID[10];
char name[15];
char kind[15];
char over[15];
char yesno[10];
char time[10];
char price[10];
};
typedef struct node
{
struct shebei data;
struct node *next; //建立一個鏈表。
}Node;
void Add(Node *equip) //添加記錄
{
Node *p,*r,*s;
char id[10]; //先用於輸入ID,也用於判斷是否跳出循環
r=equip;
s=equip->next; //使s為第一個有用的結點
while(r->next!=NULL) //這個循環的作用是使r為最後一個有用的結點
r=r->next; //將指針置於最末尾
while(1)
{
printf(">>>>>>>>>>提示:輸入0則返回主菜單!\n");
printf("\n請你輸入設備ID號:");
scanf("%s",id);
if(strcmp(id,"0")==0) break;
p=(Node *)malloc(sizeof(Node)); //申請空間
strcpy(p->data.ID,id);
printf("\n請輸入設備名稱:");
scanf("%s",p->data.name);
printf("\n請輸入設備種類:");
scanf("%s",p->data.kind);
printf("\n請輸入報廢日期:");
scanf("%s",&p->data.over);
printf("\n請輸入設備是否報廢:");
scanf("%s",&p->data.yesno);
printf("\n請輸入設備購買時間:");
scanf("%s",&p->data.time);
printf("\n請輸入設備價格:");
scanf("%s",&p->data.price);
printf(">>>>>>>>>>提示:已經完成一條記錄的添加。\n");
p->next=NULL;
r->next=p; //這一步是必需的,將p與先前的鏈表連起來構成一條新鏈表
r=p; //也是必需的.將r 又重設為新鏈的最後一個有用結點
}
}
void Modify(Node *equip)//修改
{
Node *p;
char find[20];
if(!equip->next)
{
printf("\n>>>>>>>>>>提示:沒有資料可以修改!\n");
return;
}
printf("請輸入要修改的設備ID號:");
scanf("%s",find);
p=equip->next;
while(p!=NULL)
{
if(strcmp(p->data.ID,find)==0) //如果找到的話返回的是符合要求
break;
p=p->next;
}
if(p) //若找到
{
int x;
while(1)
{
printf("完成修改請輸入0否則輸入任意數再進行修改:");
scanf("%d",&x);
if(x==0)
{break;}
printf("請輸入新設備號(原來是 %s ):",p->data.ID);
scanf("%s",p->data.ID);
printf("請輸入新設備名稱(原來是 %s ):",p->data.name);
scanf("%s",p->data.name);
printf("請輸入新設備設備種類名稱(原來是 %s ):",p->data.kind);
scanf("%s",p->data.kind);
printf("請輸入新設備報廢日期名稱(原來是 %s ):",p->data.over);
scanf("%s",p->data.over);
printf("請輸入新設備是否報廢(原來是 %s ):",p->data.yesno);
scanf("%s",p->data.yesno);
printf("請輸入新設備購買時間(原來是 %s ):",p->data.kind);
scanf("%s",p->data.time);
printf("請輸入新設備價格(原來是 %s ):",p->data.price);
scanf("%s",p->data.price);
printf("\n>>>>>>>>>>提示:該項記錄資料已經成功修改!\n");
}
}
else printf("\n>>>>>>>>>>提示:你要修改的信息不存在!\n");
}
void Disp(Node *equip)//輸出記錄
{
Node *p;
p=equip->next;
if(!p)
{
printf("\n>>>>>>>>>>提示:沒有記錄可以顯示!\n");
return;
}
printf("\t\t\t\t顯示結果\n");
printf("設備號 設備名稱 設備種類 報廢日期 是否報廢 購買時間 價格\n");
while(p)
{
printf("\n%-13s%-11s%-7s%-10s%-13s%-10s%-5s\n",p->data.ID,p->data.name,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);
p=p->next;
}
}
void Tongji(Node *equip)//統計
{
Node *p;
int sel;int flag2=0,ha=0;
p=equip->next;
char find[20];
if(!equip->next) //若鏈表為空
{
printf("\n>>>>>>>>>>提示:沒有資料可以統計分類!\n");
return;
}
printf(">>>>>>>>>>提示:\n=====>0退出\n=====>1按設備號統計\n=====>2按設備名稱統計\n");
scanf("%d",&sel);
if(sel==1)
{
printf("\n輸入你要統計分類的設備號:");
scanf("%s",find);
while(p)
{
if(strcmp(p->data.ID,find)==0)
{
flag2++;
}
if(flag2==1&&ha!=flag2)
{ printf("設備號 設備名稱 設備種類 報廢日期 是否報廢 購買時間 價格\n");
printf("\n%-13s%-11s%-7s%-10s%-13s%-10s%-5s\n",p->data.ID,p->data.name,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);
ha=flag2;
}
else if(flag2>ha){printf("\n%-13s%-11s%-7s%-10s%-13s%-10s%-5s\n",p->data.ID,p->data.name,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);ha=flag2;}
p=p->next;
}
if(flag2)
{
printf("\n*************************按設備號%s統計分類的有%d條記錄:*************************\n\n",find,flag2);
}
else {printf("\n按設備號%s統計的結果為0個\n\n",find);}
}
else if(sel==2)
{
printf("\n輸入你要統計分類的設備名稱:");
scanf("%s",find);
while(p)
{
if(strcmp(p->data.name,find)==0)
{
flag2++;
}
if(flag2==1&&ha!=flag2)
{ printf("設備號 設備名稱 設備種類 報廢日期 是否報廢 購買時間 價格\n");
printf("\n%-13s%-11s%-7s%-10s%-13s%-10s%-5s\n",p->data.ID,p->data.name,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);
ha=flag2;
}
else if(flag2>ha){printf("\n%-13s%-11s%-7s%-10s%-13s%-10s%-5s\n",p->data.ID,p->data.name,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);ha=flag2;}
p=p->next;
}
if(flag2)
{
printf("\n******************按設備名稱%s統計的有%d條記錄:********************\n\n",find,flag2);
}
else {printf("\n按設備名稱%s統計分類的結果為0個\n\n",find);}
}
else if(sel==0) return;
}
void main()
{
Node *equip;
FILE *fp;
int flag;
Node *p,*q;
printf("\t\t\t\t設備管理系統\n");
equip=(Node*)malloc(sizeof(Node));
equip->next=NULL;
p=equip;
fp=fopen("設備管理系統","wb+");
q=(Node*)malloc(sizeof(Node));
if(fread(q,sizeof(Node),1,fp)) //將文件的內容放入接點中
{
q->next=NULL;
p->next=q;
p=q; //將該接點掛入鏈表中
}
fclose(fp); //關閉文件
while(1)
{
printf("**************************************目錄**************************************");
printf("\n1添加記錄\n");
printf("\n2修改記錄\n");
printf("\n3顯示記錄\n");
printf("\n4統計分類記錄\n");
printf("\n0*-EXIT-*\n");
printf("請輸入你要操作的序號:");
scanf("%d",&flag);
switch(flag)
{
case 0: printf("\n>>>>>>>>>>提示:已經退出系統,ByeBye!\n");break;
case 1: Add(equip); break; //增加記錄
case 2: Modify(equip); break;//修改記錄
case 3: Disp(equip); break;//顯示記錄信息
case 4: Tongji(equip); break;//統計記錄
default: printf("\n>>>>>>>>>>提示:輸入錯誤!\n"); break;
}
}
}

Ⅱ c語言程序設計實驗設備管理系統

#include "stdio.h"#include "stdlib.h"#include "cstring"#define COUNT 30void start(); //函數聲明void input();void change();void sort();void dele();void output();void search();struct deviceInfor{char devno[30];int devsort; //1 代表微機 2代表列印機 3代表掃描機char devname[30];int devprice;char devbuydate[30];int devstate;char devdonedate[30];}dev[COUNT];int count=0;void main() //主函數{while(1)start(); }void start() //啟動菜單{int chi;printf(" 實驗設備管理系統\n");printf(" ********************************************\n");printf(" 1.設備信息的錄入:\n");printf(" 2.設備信息的修改:\n");printf(" 3.設備信息的分類統計:\n");printf(" 4.刪除某個設備:\n");printf(" 5.查找某個設備:\n");printf(" 6.退出系統:\n");printf(" ********************************************\n");printf(" 輸入你的選擇: ");scanf("%d",&chi);//printf("\n");if(chi==1) input();else if(chi==2) change();else if(chi==3) sort();else if(chi==4) dele();else if(chi==5) search();else if(chi==6) { printf("你已經退出設備管理系統!\n"); exit(0);}else { printf(" You Enter The Choice Is Not valid ! \n"); }}void input() //數據錄入{char flag[20];do{printf("請輸入你的設備信息:\n");printf("設備編號:");scanf("%s",dev[count].devno);printf("設備種類(1 代表微機 2代表列印機 3代表掃描機):");scanf("%d",&dev[count].devsort);printf("設備名字:");scanf("%s",dev[count].devname);printf("設備價格:");scanf("%d",&dev[count].devprice);printf("設備購買日期:");scanf("%s",dev[count].devbuydate);printf("設備狀態(1未報廢 0報廢):");scanf("%d",&dev[count].devstate);printf("設備報廢日期:");scanf("%s",dev[count].devdonedate);count++;printf("是否繼續輸入數據 y是 n否 : ");scanf("%s",flag);}while(strcmp(flag,"y")==0||strcmp(flag,"Y")==0);output();}void change() //數據修改{char ch[20],a[20];int i;printf("\nyou sure want change devInfor y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0){ printf("\nenter you want change devName:");scanf("%s",a);for(i=0;i<count;i++){if(strcmp(dev[i].devname,a)==0){ printf("\nyou sure want change dev name(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nname:"); scanf("%s",dev[i].devname);}printf("\nyou sure want change dev no(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nno"); scanf("%s",dev[i].devno);}printf("\nyou sure want change dev sort(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nsort"); scanf("%d",&dev[i].devsort);}printf("\nyou sure want dev price(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nprice"); scanf("%d",&dev[i].devprice);}printf("\nyou sure want dev done date(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\ndone date"); scanf("%s",dev[i].devdonedate);}}} }output();}void sort() //數據分類顯示{ int i,chi,sum=0,wei=0,da=0,sao=0;printf("輸入你想要統計的信息: 1(報廢的機器總數) 2(機器的總類數目)");scanf("%d",&chi);if(chi==1) {for(i=0;i<count;i++) {if(dev[i].devstate==0) sum++;}printf("報廢的機器數目為 %d \n",sum);}else if(chi==2){for(i=0;i<count;i++) {if(dev[i].devsort==1) wei++;else if(dev[i].devsort==2) da++;else if(dev[i].devsort==3) sao++;} printf("微機數目為 %d 列印機數目為 %d 掃描機數目為 %d",wei,da,sao);}else { printf("你輸入的選項不符合要求!\n");}}void dele() //數據刪除{int i,j;char c[20];printf("\nenter you want delete name :\n");printf("name:");scanf("%s",c);for(i=0;i<count;i++)if(strcmp(c,dev[i].devname)==0) break;for(j=i;j<count-1;j++)dev[j]=dev[j+1];printf("\t\t\tyou had delete %s\n",c);count--;output();}void output() //數據輸出{int i;for(i=0;i<count;i++){printf("%s %d %s %d %s %d %s\n",dev[i].devno,dev[i].devsort,dev[i].devname,dev[i].devprice,dev[i].devbuydate,dev[i].devstate,dev[i].devdonedate);}}void search() //數據查找{int i;char a[20],ch[10];printf("\nenter you want look name:");scanf("%s",a);for(i=0;i<count;i++) if(strcmp(dev[i].devname,a)==0) printf("%s %d %s %d %s %d %s\n",dev[i].devno,dev[i].devsort,dev[i].devname,dev[i].devprice,dev[i].devbuydate,dev[i].devstate,dev[i].devdonedate);}

Ⅲ c語言課題設計——實驗室設備管理系統 實現功能:(1)設備信息:設備編號、設備名稱、設備地點(實

#include"stdio.h"
#include <conio.h>
#include <stdlib.h>
//#include"FILE.h"
typedef struct shangpin
{
char name[20];
int biaohao;
int shuliang;
double jiage;
}Node;
typedef struct list
{
Node data;
struct list *next;
}List ,*Slist;
void charu(Slist &s,Node x);
int caidan()
{
int i;
while(1)
{
system("cls");
printf("\n\t\t\t 商店銷售管理系統\n\n");
printf("\t\t **********************************************\n\n");
printf("\t\t 1--添加商品 2--出售商品\n\n");
printf("\t\t 3--刪除商品 4--顯示商品\n\n");
printf("\t\t 5--查找商品 0--退出系統\n\n");
printf("\t\t **********************************************\n\n");
printf("請選擇(0-5): ");
scanf("%d",&i);
if(i<6&&i>=0)break;
}
return i;
}
void chushihua(Slist &s)
{
Slist head=new List;
head->next=NULL;
s=head;
}
void tianjia(Slist &s)
{
Node x;
Slist r,p,q;
int i=0;
r=new List;
r->next=NULL;
q=p=s->next;
while(q)
{
i++;
q=q->next;
}
printf("請輸入商品名稱、數量以及價格: ");
scanf("%s%d%lf",x.name,&x.shuliang,&x.jiage);
x.biaohao=i+1;
r->data=x;
s->next=r;
r->next=p;
}
void chu(Slist &s)
{
FILE *cp;//定義文件指針
int i=0;
Node x;

if((cp=fopen("shangpin.txt","a+"))==NULL)//打開文件
{printf("文件打開失敗!");return ;}
fseek(cp,0L,SEEK_SET);//將文件指針移動到文件開頭
while(!feof(cp))
{
fscanf(cp,"%s%d%lf",x.name,&x.shuliang,&x.jiage);//讀取文件的內容
x.biaohao=++i;
charu(s,x);//把讀到的數據插入到鏈表上
}
fclose(cp);//關閉文件
}
void charu(Slist &s,Node x)
{
Slist r,p=s->next;
r=new List;
r->next=NULL;
r->data=x;
s->next=r;
r->next=p;
}
void xieru(Slist s)
{
FILE *cp;//同上
Slist p=s->next;
if((cp=fopen("shangpin.txt","w+"))==NULL)
{printf("文件打開失敗!");return ;}//同上
while(p)
{
fprintf(cp,"%s %d %.2lf ",p->data.name,p->data.shuliang,p->data.jiage);//寫入文件中,並且以空格隔開
p=p->next;
}
fclose(cp);//關閉文件
}
Slist chazhao(Slist s,int m)
{
Slist p=s->next;
if(p==0)return 0;
if(p->next==0)return p;
if(p->data.biaohao==m)return p;
while(p->next)
{
if(p->next->data.biaohao==m)return p;
p=p->next;
}
return 0;
}
void xianshi(Slist s)
{
Slist p;
p=s->next;
printf("%10s%20s%10s%10s\n","商品編號","商品名稱","商品數量","商品價格");
while(p)
{
printf("%10d%20s%10d%10.2f\n",p->data.biaohao,p->data.name,p->data.shuliang,p->data.jiage);
p=p->next;
}

}
void shanchu(Slist &s)
{
}
void chushou(Slist &s)
{
}
void main()
{
int num;
Slist s;
chushihua(s);
chu(s);
num=caidan();
while(1)
{

switch(num)
{
case 0:exit(0);break;
case 1:tianjia(s);break;
case 2:chushou(s);break;
case 3:shanchu(s);break;
case 4:xianshi(s);break;
case 5:chazhao(s,1);break;
}
printf("按任意鍵繼續!");
getch()();
num=caidan();
}
xieru(s);
}

這是我以前給別人的一個商品管理的,用文件存儲,用的由頭結點的鏈表存儲數據的(不理解可以不管),你是拿這個自己改改不會問我呢?還是我直接給你改了?
以上回答你滿意么?

Ⅳ 通過該實驗把C語言中的幾個主要知識(如:順序結構、選擇結構、循環結構、數組、函數等)得到綜合應用。

#include <stdio.h>
#include <math.h>
#include <String.h>
#include <Bios.h>
#define ESC 27
#define ENTER 20
#define YES 'Y'
#define NO 'N'

/*********全局變數區********/
int volatile key=0,low=0; //用於鍵盤識別
char volatile search_name[5],search_flag=0; //用於尋找字元串
char volatile R=0,All=0,Error=0; //用於識別是否計算線路電阻,All用於識別是否一次計算完所有的短路點,尋找錯誤次數
char volatile Short[2]={0}; //用於記錄電路點名稱,如K1
char volatile Line_flag=0; //尋找線路位置標志
char volatile table1[20]={0}; //用於記錄串聯的位置數
char volatile table2[20]={0}; //用於記錄並聯的位置數
char volatile record[2]={0} ; //用於記錄短路點的元件存儲號
char volatile found=0; //記錄已經找到的串聯,為下一個首端做標記
float volatile Kim[5]={0}; //沖擊電流系數
char volatile kim1=0; //用於沖擊電流系數數組
float volatile VH=121; //變壓器高壓側平均電壓
struct para //結構體數組,用於存儲元件參數
{char Class; // 元件類型,0-表示線路,1表示電源,2表示電抗,3表示變壓器
char name[5]; // 元件所在名稱
float paras[4]; // 元件參數
};
/**************************/

/*******函數聲明********/
char Data_process(void);
char input(char number1,char number2,struct para *data,char type);
void Data_Dir(char num1,char num2,struct para *temp,char type2);
float find_short(char *pp,unsigned int sum,char dir0,struct para *data1);
void Line_ID(char *string1,char *string2,char dir);
char find_fun(char sum2,char dir2,char or,char head[] ,struct para *data);
/**********************/

/*函數:input(數目,參數,類型)
功能;完成電力系統元件參數的輸入
返回:是否修改值
問題:結構體不能應用浮點型數據!!輸入輸出出錯,原來是編譯器的問題!!改變內核即可
*/
char input(char number1,char number2,struct para *data,char type)
{char i=0,answer=0;
switch(type)
{case 0: //第一次輸入線路參數
{ for(i=number1;i<number2;i++)
{ data[i].Class=0;
scanf("%f,%f,%f,%f,%s",&data[i].paras[0],&data[i].paras[1],&data[i].paras[2],&data[i].paras[3],data[i].name);
printf("\n");
}
if(number1!=number2)
{ printf("The Line parameters are:\n");
printf("[Name Class Legth Rate, Res,Un(KV)]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%4d,%9.2f,%6.2f,%3.2f,%6.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
}
} break;
case 1: //輸入電源參數
{for(i=number1;i<number2;i++)
{ data[i].Class=1;
scanf("%f,%f,%f,%f,%s",&data[i].paras[0],&data[i].paras[1],&data[i].paras[2],&data[i].paras[3],data[i].name);
printf("\n");
}
if(number1!=number2)
{ printf("\nThe Power parameters are:\n");
printf("[Name Class Capability Xd' E'' Style]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%4d,%8.2f,%6.2f,%7.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
}
} break;
case 2: //輸入電抗器參數
{ for(i=number1;i<number2;i++)
{data[i].Class=2;
scanf("%f,%f,%f,%f,%s",&data[i].paras[0],&data[i].paras[1],&data[i].paras[2],&data[i].paras[3],data[i].name);
printf("\n");
}
if(number1!=number2)
{ printf("\nThe Reactance parameters are:\n");
printf("[Name Class VR(KV) IR(KA) XR Un(KV)]\n ");//(名稱,位置,額定電壓,額定電流,所在平均電壓)
for(i=number1;i<number2;i++)
{printf("%s,%2d,%10.2f,%6.2f,%6.2f,%6.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
}
} break;
case 3: //第一次輸入變壓器參數
{ for(i=number1;i<number2;i++)
{data[i].Class=3;
scanf("%f,%f,%f,%f,%s",&data[i].paras[0],&data[i].paras[1],&data[i].paras[2],&data[i].paras[3],data[i].name);
printf("\n");
}
if(number1!=number2)
{ printf("\nThe Transformer parameters are:\n");
printf("[Name Class Capability UH(KV) UL(KV) Uk(%)]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%2d,%12.2f,%8.2f,%8.2f,%6.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
}
answer=1; //完成元件的輸入
} break;
default:break;
}

printf("\nDo you sure all the parameters are right?\n");
AAA: printf("\nEnter (Y) to continue,(N) to modify,(ESC) to exit.\n");
while(bioskey(1)==0); /*檢測鍵盤是否有擊健*/
key=bioskey(0); /*讀取鍵盤輸入的掃描碼*/
low=key & 0x00ff; /*提取低8位*/
if(low==NO)
{answer=0;
printf("\nPlease input the name of the data\n");
FIND:
scanf("%s",search_name);
for(i=number1;i<number2;i++) /*尋找需要修改的線路*/
{if(strcmp(search_name,data[i].name)==0)
{search_flag=i;break;} /*找到就強制跳出循環*/
else
{search_flag=127;}
}
if(search_flag==127) /*沒有找到*/
{printf("\nInput Error! Please Check and Input again!\n");
printf("Warning:you have only ten times chances!\n");
Error++;
if(Error>10) //10次出錯
{ printf("\nTimes up! Enter anykey to exit!\n");
while(bioskey(1)==0); /*檢測鍵盤是否有擊健*/
exit(0);
Error=0;
}
else
{goto FIND;} /*繼續回去尋找*/
}

printf("Please input the new paras of the data\n");
switch(type) //修改時輸入的參數
{ case 0:{ printf("Format(Leghth(Km),Rate(@/Km),Res,Un(KV), Name)\n");

scanf("%f,%f,%f,%f,%s",&data[search_flag].paras[0],&data[search_flag].paras[1],&data[search_flag].paras[2],&data[search_flag].paras[3],data[search_flag].name);
printf("\n");

}break;
case 1:{ printf("Format(Capability(MVA),Xd',E'',Style,Name)\n");

scanf("%f,%f,%f,%f,%s",&data[search_flag].paras[0],&data[search_flag].paras[1],&data[search_flag].paras[2],&data[search_flag].paras[3],data[search_flag].name);
printf("\n");

}break;
case 2:{ printf("Format(UR(KV),IR(kA),XR(%),Un(KV),Name)\n");

scanf("%f,%f,%f,%f,%s",&data[search_flag].paras[0],&data[search_flag].paras[1],&data[search_flag].paras[2],&data[search_flag].paras[3],data[search_flag].name);
printf("\n");

}break;
case 3:{ printf("Format(Capability UH(KV),UL(KV), Uk(%),Name)\n");

scanf("%f,%f,%f,%f,%s",&data[search_flag].paras[0],&data[search_flag].paras[1],&data[search_flag].paras[2],&data[search_flag].paras[3],data[search_flag].name);
printf("\n");

}break;
default:break;
}

printf("\nThe new parameters are:\n");
switch(type)
{case 0:
{printf("The Line parameters are:\n");
printf("[Name Class Legth Rate, Res,Un(KV)]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%4d,%9.2f,%5.2f,%6.2f,%6.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
} break;
case 1:
{printf("The Power parameters are:\n");
printf("[Name Class Capability Xd' E'' Style]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%10d,%4.2f,%6.2f,%6.2f,%6.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
} break;
case 2:
{printf("The Reactance parameters are:\n");
printf("[Name Class VR(N) IR(N) XR Un(KV)]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%5d,%6.2f,%6.2f,%6.2f,%6.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
} break;
case 3:
{printf("The Transformer parameters are:\n");
printf("[Name Class Capability UH(KV) UL(KV) Uk(%)]\n ");
for(i=number1;i<number2;i++)
{printf("%s,%2d,%8.2f,%5.2f,%6.2f,%4.2f\n",data[i].name,data[i].Class,data[i].paras[0],data[i].paras[1],data[i].paras[2],data[i].paras[3]);
printf(" ");
}
} break;
default:break;
}
printf("\nThe paras of a component has been save!\n");
answer=1;
}
else if(low==YES)
{answer=1;}
else if(low==ESC)
{exit(0);}
else goto AAA; /*以上三個按鍵都不是就回去繼續等待*/

getch();
return(answer);
}
/***尋找與短路點串聯的線路元件***/
/**元件類型,0-表示線路,1表示電源,2表示電抗,3表示變壓器**/
printf("Short Name=");
printf("%s\n",data1[record[0]].name); //列印與短路點的第一個元件名稱 如,K1AD
printf("%s\n",data1[record[1]].name); //列印與短路點的第二個元件名稱 如,ACK1

count1=find_fun(sum2,dir0,0,data1[record[0]].name,data1);//以短路點為首端,找出順向串聯,如K1AD

/***find_fun()函數用於保存串聯的元件序號在table1[]中***/
for(i=0;i<count1;i++) //計算短路點到順向串聯的阻抗
{switch(data1[table1[i]].Class)
{case 0:{value1=data1[table1[i]].paras[0]; //0-線路,線路標么值
if(table2[i]!=0) //說明有並聯
{parallel1=data1[table2[i]].paras[0];
value1=value1*parallel1/(value1+parallel1);
}
aa=value1+aa;
}break;
case 1:{value2=data1[table1[i]].paras[0];
source=data1[table1[i]].paras[2]; //電源參數
Kim[kim1]=data1[table1[i]].paras[3];
kim1++;
bb=value2+bb;
}break; //1-電源
case 2:{value3=data1[table1[i]].paras[0]; //電抗,標么值
if(table2[i]!=0) //說明有並聯
{parallel2=data1[table2[i]].paras[0];
value1=value1*parallel2/(value1+parallel2);
}
cc=value3+cc;
}break; //2-電抗
case 3:{ value4=data1[table1[i]].paras[0]; //變壓器標么值,已經保存在paras[0]
if(table2[i]!=0) //說明有並聯
{parallel3=data1[table2[i]].paras[0];
value1=value1*parallel3/(value1+parallel3);
}
dd=dd+value4;
}break; //變壓器
default:break;
}
}
value=source/(aa+bb+cc+dd); //順向電流

printf("\nshort return value="); //錯誤原因,沒有找到電源!
printf("%5.3f\n",value);
return(value);

}

main()
{printf("===========================Welcome To Use This Program=====================\n");
printf("==============================Statement==================================\n");
printf("\n 1 You must predigest the circuit first.\n");
printf("\n 2 You must name to every node by two letter,such as 'AB'\n");
printf("\n 3 You must follow the input format.\n");
printf("\n 4 Class [Line-0,Power sourse-1,Resistance-2,Transformer-3] \n");
printf("\n Now you can use the program if you have read the staement carefully!\n");
printf("\n\n");
Data_process();
}

估計你還是學計算機的,這么簡單的問題,自己多琢磨一下吧,C語言可是很經典的東西,以上僅供參考。