當前位置:首頁 » 編程軟體 » 編程實驗類型

編程實驗類型

發布時間: 2022-10-10 09:58:01

❶ 誰能給我51單片機C語言編程實驗報告

學習單片機實在不是件易事,一來要購買高價格的編程器,模擬器,二來要學習編程語言,還有眾多種類的單片機選擇真是件讓人頭痛的事。在眾多單片機中 51 架構的晶元風行很久,學習資料也相對很多,是初學的較好的選擇之一。51 的編程語言常用的有二種,一種是匯編語言,一種是 C 語言。匯編語言的機器代碼生成效率很高但可讀性卻並不強,復雜一點的程序就更是難讀懂,而 C 語言在大多數情況下其機器代碼生成效率和匯編語言相當,但可讀性和可移植性卻遠遠超過匯編語言,而且 C 語言還可以嵌入匯編來解決高時效性的代碼編寫問題。對於開發周期來說,中大型的軟體編寫用 C 語言的開發周期通常要小於匯編語言很多。

❷ 請教高手,C語言編程指針實驗

void PrintMaxScoreAndNum(int TotalNum)
{
/* 斷言,檢測入參*/
Assert(40 >= TotalNum);

int i,MaxScore = 0;
int Score[TotalNum] = {0};
/* 輸入成績 */
for(i = 0; i < TotalNum; i++)
{
scanf("%d", &Score[i]);
}

int *p = NULL;
p = Score;
/* 得到最高分數 */
for(i = 0; i < TotalNum; i++,p++)
{
if(MaxScore < *p)
{
MaxScore = *p;
}
}
p = Score;
printf("本課程最高分為:%d\n", MaxScore);
printf("獲得最高分的學號為:\n");
for(i = 0; i < TotalNum; i++,p++)
{
if(MaxScore == *p)
{
printf("%d\n", i);
}
}
return;
}
不知這樣行否樓主?

❸ 數據結構上機實驗(編程)(單鏈表的基本操作)

我們正在學數據結構,兩星期前寫好了線性表的所有基本操作,運行全部正確。包括InitList、DestoryList、ClearList、ListEmpty、ListLength、GetElem、LocateElem、PriorElem、NextElem、ListInsert、ListDelete、ListTraverse

我所編譯的環境是VC++ 6.0,有三個文件linklist.h linklist.cpp main.cpp 至於怎樣用你應該知道的,我就不多說了。

========================linklist.h============================
#include <iostream>
using namespace std;

#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2

typedef int Status;
typedef int ElemType;

//線性表的單鏈表存儲結構
typedef struct LNode
{
ElemType data;
int len;
struct LNode * next;
}LNode,*LinkList;

void CreateList_L(LinkList &L,int n);

int ListLength(LinkList L);

Status ListInsert(LinkList & L,int i,ElemType e);

Status ListDelete(LinkList & L,int i,ElemType & e);

ElemType GetElem(LinkList L,int i);

Status EmptyList_L(LinkList L);

int LocateElem(LinkList L,ElemType e);

Status PriorElem(LinkList L,ElemType curr_e,ElemType & e);

Status NextElem(LinkList L,ElemType curr_e,ElemType & e);

Status ListTraverse(LinkList L);

Status ClearList_L(LinkList & L);

void DestoryList_L(LinkList & L);

==========================linklist.cpp=======================
#include "linklist.h"

int LISTLEN = 0;

//逆序輸入n個元素的值
//創建帶有頭結點的線性單鏈表
void CreateList_L(LinkList &L,int n)
{

L = (LinkList)malloc(sizeof(LNode));
L->len = 0;
L->next = NULL;

for(int i = n;i>0;--i)
{
LinkList p = (LinkList)malloc(sizeof(LNode));
cout<<"請輸入元素的值(前插):";
cin>>p->data;
p->next = L->next; //插入到表頭
L->next = p;
L->len++;
LISTLEN++;
}
}

//求表長
int ListLength(LinkList L)
{
int len1=0;
LinkList p = L->next;
while(p)
{
p = p->next;
len1++;
}
return len1;
//return L->len;

}

//在鏈表的第i位之前插入元素e
// i 的合法位置是:1 <= i <= ListLength(L)+1
Status ListInsert(LinkList & L,int i,ElemType e)
{
if(i<1 || i>ListLength(L)+1)
{
cout<<"插入失敗! 訪問越界..."<<endl;
return ERROR;
}
else
{
int j;
LinkList p = L;
for(j = 0;j<i-1;j++) //for循環結束後p將指向第i-1個元素,即應該在p後插入元素e
p = p->next;
LinkList s = (LinkList)malloc(sizeof(LNode));
s->data = e;
s->next = p->next;
p->next = s;

L->len++;
return TRUE;
}
}

//刪除鏈表的第i個元素,並用e返回值
//i的合法范圍是:0<i<ListLength(L)+1
Status ListDelete(LinkList & L,int i,ElemType & e)
{
if(i<1 || i>ListLength(L))
{
cout<<"訪問越界..."<<endl;
return ERROR;
}
else
{
LinkList p = L;
int j;
for(j = 0;j < i-1;j++) //for循環後指針p將指向要刪除的元素的前驅結點
p = p->next;
e = p->next->data;
LinkList q = p->next;
p->next = q ->next;
L->len--;
free(q);

return TRUE;
}
}

//獲取表中第i個元素
//i的合法取值范圍是:0 < i < ListLength(L)+1
ElemType GetElem(LinkList L,int i)
{
if(i<1 || i>ListLength(L))
{
cout<<"取值非法! 鏈表中無此位序元素"<<endl;
return ERROR;
}
else
{
LinkList p = L;
int j;
for(j = 0;j<i;j++)
p = p->next;
return p->data;
}

}

//判斷鏈表是否為空
Status EmptyList_L(LinkList L)
{
if(L->next == NULL)
return TRUE;
return ERROR;
}

//在鏈表中查找定位元素e的位序,並通過函數返回
int LocateElem(LinkList L,ElemType e)
{
int i = 0;
LinkList p = L;
while(p->next && p->next->data != e)
{
p = p->next;
i++;
}
if(p->next == NULL)
{
cout<<"在鏈表中找不到元素 "<<e<<endl;
return ERROR;
}

return (i+1);
}

//求當前元素curr_e的直接前驅元素,用e返回其值
Status PriorElem(LinkList L,ElemType curr_e,ElemType & e)
{
LinkList p = L;
while(p->next && curr_e != p->next->data)
p = p->next;
if(p->next == NULL)
{
cout<<"在鏈表中找不到元素 "<<curr_e<<" ,無法求其前驅元素!"<<endl;
return ERROR;
}
if(p == L)
{
cout<<"元素 "<<curr_e<<" 是鏈表中的首元元素,無前驅..."<<endl;
return ERROR;
}
e = p->data;
return OK;
}

/*
//求當前元素curr_e的直接後繼元素,用e返回其值
Status NextElem(LinkList L,ElemType curr_e,ElemType & e)
{
LinkList p = L->next;
//cout<<curr_e<<endl;

//cout<<p->next->data<<endl;

if(p == NULL)
{
cout<<"鏈表是個空表!"<<endl;
return ERROR;
}

if(p->next == NULL)
{
cout<<"鏈表中只有一個元素,無後繼..."<<endl;
return ERROR;
}

while(p->next && curr_e != p->data)
{
//cout<<"while"<<endl;
p = p->next;
}
cout<<"p->data = "<<p->data<<endl;

if(p->data != curr_e)
{
cout<<"111"<<endl;
cout<<"在鏈表中找不到元素 "<<curr_e<<" ,無法求其後繼元素!"<<endl;
return ERROR;
}

if(p->next == NULL && curr_e == p->data)
{
cout<<"222"<<endl;
cout<<"元素 "<<curr_e<<" 是鏈表中的尾元元素,無後繼..."<<endl;
return ERROR;
}
cout<<"333"<<endl;
e = p->data;
return OK;
}
*/

//求當前元素curr_e的直接後繼元素,用e返回其值
Status NextElem(LinkList L,ElemType curr_e,ElemType & e)
{
LinkList p = L->next;
while(p && p->data != curr_e)
p = p->next;
if(p == L->next)
{
if(p == NULL)
{
cout<<"\n鏈表是一個空表,無法做取後繼操作!"<<endl;
return ERROR;
}
else
{
cout<<"\n鏈表中只有一個元素,無法求其後繼..."<<endl;
return ERROR;

}
}
if(p == NULL)
{
cout<<"\n在鏈表中未能找到元素: "<<curr_e<<endl;
return ERROR;
}
if(p->next == NULL)
{
cout<<"\n元素 "<<curr_e<<" 是鏈表的尾元元素,無法求其後繼..."<<endl;
return ERROR;
}
e = p->next->data;
return OK;

}

//對鏈表進行遍歷操作
Status ListTraverse(LinkList L)
{
LinkList p = L->next;

if(LISTLEN == 0)
{
cout<<"\n鏈表中除頭結點以外的所有內容已被釋放,是一個空表!"<<endl;
cout<<"\n遍歷失敗..."<<endl;
return ERROR;
}
if(LISTLEN == -1)
{
cout<<"\n所有內容已被釋放,鏈表已被銷毀!"<<endl;
cout<<"\n遍歷失敗..."<<endl;
return ERROR;
}
while(p != NULL)
{
cout<<p->data<<" ";
p = p->next;
}
cout<<"\n遍歷成功!"<<endl;
return OK;
}

//清空鏈表的內容
//單鏈表的清空是指釋放除頭結點以外的內存空間
Status ClearList_L(LinkList & L)
{
LinkList p = L;
while(p->next)
{
LinkList m = p->next;
free(p);
p = m;
}
L->next = NULL;
LISTLEN = 0;
return OK;
}

//銷毀鏈表
//單鏈表的釋放是指釋放鏈表的所有結點內存空間
void DestoryList_L(LinkList & L)
{
LinkList p = L;
while(p->next)
{
LinkList m = p->next;
free(p);
p = m;
}

//free (p);
//free (L);
LISTLEN = -1;
}

=========================main.cpp=======================
#include "linklist.h"

int main()
{
LinkList L;
ElemType e;
ElemType curr_e;
int n;
int status; //返回函數執行狀態

cout<<"請輸入所需創建的元素個數:";
cin>>n;
cout<<endl;

//創建單鏈表
CreateList_L(L,n);
cout<<endl;

//遍歷
status = ListTraverse(L);

//返回鏈表表長
cout<<"\n單鏈表的長度是: "<<ListLength(L)<<endl;

//鏈表的插入操作
cout<<"\n請輸入需要插入元素的位置: ";
cin>>n;
cout<<"\n請輸入插入的元素值: ";
cin>>e;
status = ListInsert(L,n,e);
if(status)
cout<<"\n鏈表元素插入成功!"<<endl;
else
cout<<"\n鏈表元素插入失敗!"<<endl;

status = ListTraverse(L);
cout<<endl;

//單鏈表的刪除操作
cout<<"請輸入需要刪除的元素的位置: ";
cin>>n;
status = ListDelete(L,n,e);
if(status)
{
cout<<"\n刪除成功!";
cout<<" 刪除的元素是: "<<e<<endl;
}
else
cout<<"\n刪除失敗..."<<endl;

status = ListTraverse(L);
cout<<endl;

//獲取單鏈表的元素
cout<<"請輸入你想獲取的元素在鏈表中的位置: ";
cin>>n;
e = GetElem(L,n);
if(n > 0 && n <= L->len)
cout<<"\n單鏈表第"<< n <<"個元素值是: "<<e<<endl;

//單鏈表判空操作
status = EmptyList_L(L);
if(status)
cout<<"\n單鏈表為空表!"<<endl;
else
cout<<"\n單鏈表非空,其中含有元素."<<endl;

//查找定位元素
cout<<"\n請輸入所需查找的元素: ";
cin>>e;
n = LocateElem(L,e);
if(n)
cout<<"\n元素 "<<e<<" 在鏈表中的位置是: "<<n<<endl;

//前驅操作
cout<<"\n需要求其前驅的元素值: ";
cin>>curr_e;
status = PriorElem(L,curr_e,e);
if(status)
cout<<"\n元素 "<<curr_e<<" 的前驅是: "<<e<<endl;

//後繼操作
cout<<"\n需要求其後繼的元素值: ";
cin>>curr_e;
status = NextElem(L,curr_e,e);
if(status)
cout<<"\n元素 "<<curr_e<<" 的後繼是: "<<e<<endl;

//單鏈表的清空操作
cout<<"\n調用清空鏈表函數";
status = ClearList_L(L);

cout<<endl;

status = ListTraverse(L);

//單鏈表的銷毀操作
cout<<"\n調用鏈表銷毀函數";
DestoryList_L(L);

cout<<endl;

status = ListTraverse(L);

cout<<endl;

return 0;
}

❹ 急 急 急 急 急 急 C語言編程實驗報告

struct student
{
int num;
char name[10][10];
float score[3];
};
float ave[3], t[3]={0}, s=0, tv;
int main()
{
void input(struct student stu[], int n, int m);
void average(struct student stu[], int n, int m);
void print(struct student stu[], int n, int m);
void maximum(struct student stu[], int n, int m);
struct student stu[10];
input(stu, 10, 3);
average(stu, 10, 3);
print(stu, 10, 3);
maximum(stu, 10, 3);
return 0;
}

void input(struct student stu[], int n, int m)
{
int i, j;
printf("NO name score1 score2 score3 \n");
for(i=0; i<n; i++)
{
scanf("%d", &stu[i].num);
scanf("%s", stu[i].name[i]);
for(j=0; j<m; j++)
{
scanf("%f", &stu[i].score[j]);
}
}
}

void average(struct student stu[], int n, int m)
{
int i, j;
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
t[i]+=stu[i].score[j];
}
s+=t[i];
ave[i]=t[i]/n;
}
tv=s/n;
}
void print(struct student stu[], int n, int m)
{
int i, j;
printf("\n\n NO name score1 score2 score3 total average \n");
for(i=0; i<n; i++)
{
printf("%4d", stu[i].num);
printf("%4s", stu[i].name[i]);
for(j=0; j<m; j++)
{
printf("%.2f ", stu[i].score[j]);
}
printf("%.2f %.2f\n", t[i], ave[i]);
}
printf("\n\nt-v:%.2f", tv);
}
void maximum(struct student stu[], int n, int m)
{
int i, j;
float max;
max=ave[0];
for(i=1; i<n; i++)
if(max<ave[i]) max=ave[i];
printf("\n\n NO name score1 score2 score3 total average\n");
for(i=0; i<n; i++)
{
if(ave[i]==max)
{
printf("%4d", stu[i].num);
printf("%4s", stu[i].name[i]);
for(j=0; j<m; j++)
printf("%.2f ", stu[i].score[j]);
printf("%.2f %.2f\n", t[i], ave[i]);
}
}
}
運行情況符合你的要求,我就不寫了,太費事
流程圖也太費事了,沒時間了

❺ 求高手幫忙下Linux系統的Shell編程,我們的一個實驗課課題,詳見問題補充,謝謝

#!/bin/bash
dir_source="/home/hnsd/workdata/"

yyyymmdd=`date +%Y%m%d`

data_time=`date +%p`

if [ "${data_time}" = "AM" ]; then
workdata=workdata1
dir_back="/home/hnsd/disk1backup/"
else
workdata=workdata2
dir_back="/dev/disk2backup/"
fi

tar zcvf ${dir_back}${yyyymmdd}_${workdata}.tar.gz ${dir_source}*

crontab 寫法為

* 12 * * * 腳本絕對路徑
30 17 * * * 腳本絕對路徑

java編程實驗,類與對象,設計學生類,每個學生有兩門課程,

可選中1個或多個下面的關鍵詞,搜索相關資料。也可直接點「搜索資料」搜索整個問題。

  • java 編程
  • 對象

  • 學生 類

❼ vb編程實驗題

PrivateSubCommand1_Click()
DimHAsInteger,LAsInteger,nAsInteger
n=0
Cls
Print"符合情況的條件有:"
Fori=1To35
Forj=1To35
If4*i+j*2=100Then
Print"兔子的數量是"&i&"只,雞的數量是"&j&"只"
n=n+1
EndIf
Nextj
Nexti
Print

Print"這樣的情況一共有"&n&"種"
EndSub

❽ C語言函數編程實驗

像這種題比較長,雖說是基礎題但是也要花點時間。很少有人會給完整的回答的。
建議找個人單獨給你回答,同時還可以帶你復習一下,怎麼自己寫出來。

❾ c++編程實驗題求助




min和max這個其實在某個頭文件有的。等等!啥頭文件?!忘了。。。。。。那。。。。。。用萬能頭吧!

程序若有錯,請提醒!




#include<bits/stdc++.h>

using namespace std;

long long n,a[10000009];

double ans=0;

int main() {

cin>>n;

for(int i=0;i<n;i++)cin>>a[i];

cout<<*max_element(a,a+n)<<endl<<*min_element(a,a+n)<<endl;

for(int i=0;i<n;i++) {

if(i==max_element(a,a+n)||i!=max_element(a,a+n))continue;

ans+=a[i];

}

cout<<fixed<<setprecision(2)<<ans;

return 0;

}






輸出樣例#1:輸出樣例#1:

44

1 2 3 4 1

2.50


輸出樣例#2:輸出樣例#2:

55

1 3 2 5 41

3.33


輸出樣例#3:輸出樣例#3:

10 100

1 2 3 1 2 7 3 4 100 9 1

3.97










望採納!!!

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:333
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:376
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:610
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:31
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:107
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:941
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:739
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:802
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:510
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:371