編程題(15_01.c)
結構
struct student
{
long num
char name[20]
int score
struct student *next
}
鏈表練習:
(1).編寫函數struct student * creat(int n),創建一個按學號升序排列的新鏈表,每個鏈表中的結點中
的學號、成績由鍵盤輸入,一共n個節點。
(2).編寫函數void print(struct student *head),輸出鏈表,格式每行一個結點,包括學號,姓名,分數。
(3).編寫函數struct student * merge(struct student *a,struct student *b), 將已知的a,b兩個鏈表
按學號升序合并,若學號相同則保留成績高的結點。
(4).編寫函數struct student * del(struct student *a,struct student *b),從a鏈表中刪除b鏈表中有
相同學號的那些結點。
(5).編寫main函數,調用函數creat建立2個鏈表a,b,用print輸出倆個鏈表;調用函數merge升序合并2個
鏈表,并輸出結果;調用函數del實現a-b,并輸出結果。
a:
20304,xxxx,75,
20311,yyyy,89
20303,zzzz,62
20307,aaaa,87
20320,bbbb,79
b:
20302,dddd,65
20301,cccc,99
20311,yyyy,87
20323,kkkk,88
20307,aaaa,92
20322,pppp,83
標簽:
student
struct
score
long
上傳時間:
2016-04-13
上傳用戶:zxc23456789
找一個最小的自然數,使它等于不同的兩組三個自然數的三次冪之和,即找最小的x,使得:x=a*a*a+b*b*b+c*c*c = d*d*d+e*e*e+f*f*f 其中,a,b,c,d,e,f都是自然數,a<=b<=c, d<=e<=f [a,b,c]!=[d,e,f]
進一步,是否還存在另外一個自然數滿足上述條件,可能的話請輸出其結果
標簽:
上傳時間:
2017-05-16
上傳用戶:vodssv
#include <iostream.h>
#include <string.h>
#include <iomanip.h>
#include "Stud.h"
Stud::Stud(){}
char *Stud::getno() //獲取學號
{
return no;
}
char *Stud::getname() //獲取姓名
{
return name;
}
char *Stud::getsex() //獲取性別
{
return sex;
}
char *Stud::getminzu() //獲取民族
{
return minzu;
}
char *Stud::getaddress() //獲取出生地
{
return address;
}
char *Stud::getbirth() //獲取出生年月
{
return birth;
}
int Stud::gettag() //獲取姓名
{
return tag;
}
void Stud::changeno(char n[]) //設置學號
{
strcpy(no,n);
}
void Stud::changename(char na[]) //設置姓名
{
strcpy(name,na);
}
void Stud::changesex(char s[]) //設置性別
{
strcpy(sex,s);
}
void Stud::changeminzu(char m[]) //設置民族
{
strcpy(minzu,m);
}
void Stud::changeaddress(char a[]) //設置出生地
{
strcpy(address,a);
}
void Stud::changebirth(char b[]) //設置出生年月
{
strcpy(birth,b);
}
void Stud::addstudent(char *rn,char *rna) //增加學生
{
strcpy(no,rn);
strcpy(name,rna);
}
void Stud::addstudent(char *rn,char *rna,char *rs,char *rm,char *ra,char *rb) //增加學生
{
tag=0;
strcpy(no,rn);
strcpy(name,rna);
strcpy(sex,rs);
strcpy(minzu,rm);
strcpy(address,ra);
strcpy(birth,rb);
}
void Stud::delstud() //設置刪除標記
{
tag=1;
}
void Stud::disp() //輸出學生信息
{
cout<<setw(15)<<no<<setw(10)<<name<<setw(10)<<sex<<setw(10)<<minzu<<setw(10)<<address<<setw(10)<<birth<<endl;
}
void Stud::display() //輸出學生信息
{
cout<<setw(15)<<no<<setw(10)<<name;
}
標簽:
學生
上傳時間:
2016-12-29
上傳用戶:767483511