當前位置:首頁 » 編程語言 » c語言程序設計課後答案

c語言程序設計課後答案

發布時間: 2023-08-19 05:33:41

c語言程序設計 譚浩強第四版第三章課後題答案

第三章 部分答案
3.6寫出以下程序運行的結果。
main()
{char c1=』a』,c2=』b』,c3=』c』,c4=』\101』,c5=』\116』;
printf(「a%cb%c\tc%c\tabc\n」,c1,c2,c3);
printf(「\t\b%c %c」,c4,c5);
}
解:
aaㄩbbㄩㄩㄩccㄩㄩㄩㄩㄩㄩabc
AㄩN
3.7要將"China"譯成密碼,解碼規律是:用原來字母後面的第4個字母代替原來的字母.例如,字母"A"後面第4個字母是"E"."E"代替"A"。因此,"China"應譯為"Glmre"。請編一程序,用賦初值的方法使cl、c2、c3、c4、c5五個變數的值分別為,』C』、』h』、』i』、』n』、』a』,經過運算,使c1、c2、c3、c4、c5分別變為』G』、』l』、』m』、』r』、』e』,並輸出。
解:
#include <stdio.h>
main()
{ char c1=』C』,c2=』h』,c3=』i』,c4=』n』,c5=』a』;
c1+=4;
c2+=4;
c3+=4;
c4+=4;
c5+=4;
printf("密碼是%c%c%c%c%c\n",c1,c2,c3,c4,c5);
}
運行結果:
密碼是Glmre
3.9求下面算術表達式的值。
(1)x+a%3*(int)(x+y)%2/4
設x=2.5,a=7,y=4.7
(2)(float)(a+b)/2+(int)x%(int)y
設a=2,b=3,x=3.5,y=2.5
(1)2.5
(2)3.5
3.10寫出程序運行的結果。
main()
{int i,j,m,n;
i=8;
j=10;
m=++i;
n=j++;
printf(「%d,%d,%d,%d」,i,j,m,n);
}
解:
9,11,9,10
3.12 寫出下面表達式運算後a的值,設原來a=12。設a和n都已定義為整型變數。
(1)a+=a (2) a-=2 (3) a*=2+3 (4)a/=a+a
(5) a%=(n%=2),n的值等於5
(6)a+=a-=a*=a
解:
(1) 24 (2) 10 (3) 60 (4) 0 (5) 0 (6) 0

② 求c語言程序設計答案

#include
<fstream>
#include
<string.h>
#include
<iostream>
#include
<conio.h>//用getch();
using
namespace
std;
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌Student類﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
class
Student
{
public:
char
name[20];
char
Class[20];
char
Id[20];
int
Cnum;
//C課程得分
int
Mnum;
//數學課程得分
int
Enum;
//英語課程得分
int
Gnum;
//體育
int
sum;
//總分
int
ave;
//平均分
Student
*
Next;
void
Input()
{
cout<<"\t\t請輸入學生的姓名:";
cin>>name;
cout<<"\t\t請輸入學生的班級:";
cin>>Class;
cout<<"\t\t請輸入學生的學號:";
cin>>Id;
cout<<"\t\t請輸入C++的成績:";
cin>>Cnum;
cout<<"\t\t請輸入數學課程的成績:";
cin>>Mnum;
cout<<"\t\t請輸入英語課程的成績:";
cin>>Enum;
cout<<"\t\t請輸入日語的成績:";
cin>>Gnum;
sum=Cnum+Mnum+Enum+Gnum;
ave=(Cnum+Mnum+Enum+Gnum)/4;
}
void
ReadFile(istream
&
in)
{
in>>name>>Class>>Id>>Cnum>>Mnum>>Enum>>Gnum>>ave>>sum;
}
void
Show()
{
cout<<"姓名:"<<name<<endl<<"班級:"<<Class<<endl<<"學號:"<<Id<<endl<<"C++:"<<Cnum<<endl
<<"數學:"<<Mnum<<endl<<"外語:"<<Enum<<endl<<"日語:"<<Gnum<<endl<<"平均成績:"<<ave<<endl<<"總成績:"<<sum<<endl<<endl<<endl;
}
};
//﹌﹌﹌﹌﹌﹌﹌﹌﹌Studentmassage類﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
class
Studentmassage
{
public:
Studentmassage();
~Studentmassage();
void
ShowMenu();
void
Find();
void
Save();
void
ModifyItem();
void
RemoveItem();
void
Swap(Student
*,Student
*);
void
Sort();
int
ListCount();
void
Display()
{
for(Student
*
p=Head->Next;p!=End;p=p->Next)
p->Show();
cout<<"輸入任意字元!繼續……";
getch();
}
void
AddItem()
{
End->Input();
End->Next=new
Student;
End=End->Next;
cout<<"添加成功!"<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
private:
Student
*
Head,*
End;
ifstream
in;
ofstream
out;
Student
*FindItem(char
*
name)
{
for(Student
*
p=Head;p->Next!=End;p=p->Next)
if(!strcmp(p->Next->name,name))return
p;
return
NULL;
}
Student
*FindID(char
*
Id)
{
for(Student
*
p=Head;p->Next!=End;p=p->Next)
if(!strcmp(p->Next->Id,Id))return
p;
return
NULL;
}
Student
*FindCLASS(char
*
Class)
{
for(Student
*
p=Head;p->Next!=End;p=p->Next)
if(!strcmp(p->Next->Class,Class))return
p;
return
NULL;
}
}Grade;
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌構造函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Studentmassage::Studentmassage()
{
Head=new
Student;
Head->Next=new
Student;
End=Head->Next;
in.open("sort.txt");
if(!in)
cout<<"這是一個新系統,無學生信息。請先輸入。"<<endl;
else
{
while(!in.eof())
{
End->ReadFile(in);
if(End->name[0]=='\0')break;
End->Next=new
Student;
End=End->Next;
}
in.close();
cout<<"\t\t讀取學生信息成功!"<<endl;
}
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌析構函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Studentmassage::~Studentmassage()
{
Save();
for(Student
*
temp;Head->Next!=End;)
{
temp=Head->Next;
Head->Next=Head->Next->Next;
delete
temp;
}
delete
Head,End;
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌菜單﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::ShowMenu()
{
cout<<"〓〓〓〓〓〓〓〓〓〓










〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓★★★★★
★★★★★★★
★★★★★〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

1.增加學生成績

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

2.顯示學生成績

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

3.排序統計成績

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

4.查找學生成績

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

5.刪除學生成績

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

6.修改學生信息

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★

0.安全退出系統

★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"\n\t\t\n\t\t請選擇:";
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌查找函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::Find()
{
char
name[20]
,Id[10],Class[20];
int
x;
Student
*
p=NULL;
cout<<"\n\t\t*********************************\n";
cout<<"\t\t※
1.按學生的姓名查找\n\t\t※
2.按學生學號查找\n\t\t※
3.按學生班級查找";
cout<<"\n\t\t*********************************\n請選擇:";
cin>>x;
switch(x)
{
case
1:{cout<<"\t\t請輸入要查找的學生的姓名:";cin>>name;
if(p=FindItem(name))
{
p->Next->Show();
cout<<"輸入任意字元!繼續……";
getch();
}
else
{
cout<<"\t\t沒有找到該姓名的學生!"<<'\n'<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
}break;
case
2:
{
cout<<"\t\t請輸入要查找的學生的學號:";cin>>Id;
if(p=FindID(Id))
{
p->Next->Show();
cout<<"輸入任意字元!繼續……";
getch();
}
else
{
cout<<"\t\t沒有找到該學號的學生!"<<'\n'<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
}break;
case
3:{cout<<"\t\t請輸入要查找的學生的班級:";cin>>Class;
if(p=FindCLASS(Class))
{
p->Next->Show();
cout<<"輸入任意字元!繼續……";
getch();
}
else
{
cout<<"\t\t沒有找到該班級的學生!"<<'\n'<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
}break;
}
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌修改信息﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::ModifyItem()
//修改信息
{
char
ID[20];
Student
*
p=NULL;
cout<<"\t\t請輸入要修改的人的學號:";cin>>ID;
if(p=FindID(ID))
{
cout<<"\t\t已找到學生的信息,請輸入新的信息!"<<endl;
p->Next->Input();
cout<<"修改成功!"<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
else
{
cout<<"\t\t沒有找到!"<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌刪除信息﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::RemoveItem()
//
刪除信息
{
char
ID[20];
Student
*
p=NULL,*temp=NULL;
cout<<"\t\t請輸入要刪除的學生的學號:";cin>>ID;
if(p=FindID(ID))
{
temp=p->Next;
p->Next=p->Next->Next;
delete
temp;
cout<<"\t\t刪除成功!"<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
else
{
cout<<"\t\t沒有找到!"<<endl;
cout<<"輸入任意字元!繼續……";
getch();
}
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::Swap(Student
*p1,
Student
*p2)
{
Student
*temp=new
Student;
strcpy(temp->name,p1->name);
strcpy(temp->Id,p1->Id);
temp->Cnum=p1->Cnum;
temp->Mnum=p1->Mnum;
temp->Enum=p1->Enum;
temp->sum=p1->sum;
strcpy(p1->name,p2->name);
strcpy(p1->Id,p2->Id);
p1->Cnum=p2->Cnum;
p1->Mnum=p2->Mnum;
p1->Enum=p2->Enum;
p1->sum=p2->sum;
strcpy(p2->name,temp->name);
strcpy(p2->Id,temp->Id);
p2->Cnum=temp->Cnum;
p2->Mnum=temp->Mnum;
p2->Enum=temp->Enum;
p2->sum=temp->sum;
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
int
Studentmassage::ListCount()//統計當前的記錄總數
{
if(!
Head)
return
0;
int
n=0;
for(Student
*
p=Head->Next;p!=End;p=p->Next)
{
n++;
}
return
n;
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::Sort()//對當前學生進行排序
{
cout
<<"Sorting..."<<endl;
Student
*p=NULL,*p1=NULL,*k=NULL;
int
n=Studentmassage::ListCount();
if(n<2)
return;
for(p=Head->Next;p!=End;p=p->Next)
for(k=p->Next;k!=End;k=k->Next)
{
if(p->sum>k->sum)
{
Studentmassage::Swap(p,k);
}
}
cout
<<"排序完成!"<<endl;
getch();
return;
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌保存函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
void
Studentmassage::Save()
{
out.open("sort.txt");
for(Student
*p=Head->Next;p!=End;p=p->Next)
out<<p->name<<"\t"<<p->Class<<"\t"<<p->Id<<"\t"
<<p->Cnum<<"\t"<<p->Mnum<<"\t"<<p->Enum<<"\t"<<p->Gnum<<"\t"<<p->ave<<"\t"<<p->sum<<'\n';
out.close();
}
void
code()
//密碼
{
char
s1[20]="123",s2[20];
cout<<"請輸入密碼:";
while(cin>>s2)
{
if(!strcmp(s1,s2))
{
Grade.ModifyItem();break;
}
else
cout<<"你輸入的密碼不正確,請重新輸入:";
}
}
//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌主函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
int
main()
{
int
x,i=0;
bool
quit=false;
cout<<"\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§"<<endl;
for(i=0;i<3;i++)
cout<<"\t\t◎\t\t\t\t\t\t
◎"<<endl;
cout<<"\t\t◎★★★★【
歡迎進入學生成績管理系統
】★★★★◎"<<endl;
for(i=0;i<3;i++)
cout<<"\t\t◎\t\t\t\t\t\t
◎"<<endl;
cout<<"\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§\n"<<endl;;
cout<<"請按任意鍵開始……";
getch();
while(!quit)
{
system("cls");
Grade.ShowMenu();
cin>>x;
switch(x)
{
case
0:cout<<"★★★★感謝您的使用★★★★"<<endl;quit=true;break;
case
1:Grade.AddItem();break;
case
2:Grade.Display();break;
case
3:Grade.Sort();break;
case
4:Grade.Find();break;
case
5:Grade.RemoveItem();break;
case
6:code();break;
}
}
return
0;
}
我稍微改了下,應該可以用~
額~~你們一定要C編嗎~C++不可以嘛?

③ C語言程序設計,求答案。萬分感謝!

第一題的:

#include<stdio.h>
int main()
{
char c;
scanf("%c",&c);
if('a'<=c&&c<='z')
printf("%c\n",char(c-32));
else if('A'<=c&&c<='Z')
printf("%c\n",char(c+32));
else
printf("what you input is not a letter! ");
return 0;
}

第二題的:
#include<stdio.h>
int main()
{ int x,y;
printf("Please input your number x:\n");
scanf("%d",&x);
if(x>-1)
y=2*x;
else if(x<-1)
y=4+x;
else y=3;
printf("%d",y);

return 0;
}

第三題:
#include<stdio.h>
int main()
{
int n;
printf("Please input a integer number:\n");
scanf("%d",&n);
(n%2==0)?(printf("%d is Even\n",n)):(printf("%d is Odd\n",n));
return 0;
}

第四題的:
#include<stdio.h>
int main()
{
float x,y;
printf("請輸入員工的業績金額(萬元):\n");
scanf("%f",&x);
if(x<1)
y=1.03*x;
else if(x>=1&&x<5)
y=1.1*x;
else if(x>=5&&x<20)
y=1.5*x;
else y=1.2*x;
printf("該員工的獎金數是%g萬元\n",y);
return 0;

}

④ C語言程序設計教程(第二版) 周宇 課後答案

二、 1. I love China! printf("we are students.\n") 2. 6 項目實訓題參考答案 1.編寫一個C程序,輸出以下信息: * * * * * * * * * * * * * * * * * * * * I am a student! * * * * * * * * * * * * * * * * * * * * main() { printf("********************\n"); printf(" I am a student!\n "); printf("********************\n"); } 2222....已知立方體的長、寬、高分別是10cm、20cm、15cm,編寫程序,求立方體體積。 解: main() { int a,b,c,v; a=10; b=20; c=15; v=a*b*c; printf("v=%d",v); } 本程序運行結果為: v=3000 第第第第2章章章章 編制編制編制編制C程序的基礎知識程序的基礎知識程序的基礎知識程序的基礎知識 一 選擇題 C B A B A C C 二 操作題 2 21. 3,2,-8,2 3.000000,2.500000,-8.000000 2. ABC DE FGH why is 21+35 equal 52 3. 3 1 4 3 2 3 1 2 4. aa bb cc abc A N 項目實訓題 1.定義一個符號常量M為5和一個變數n值為2,把它們的乘積輸出。 #define M 5 main() { int n,c; n=2; c=M*n; printf("%d\n",c); } 2.編程求下面算術表達式的值。 (1)x+a%3*(int)(x+y)%2/4,設x=2.5,a=7,y=4.7; (2)(float)(a+b)/2+(int)x%(int)y,設a=2,b=3,x=3.5,y=2.5。 (1)main() { int a=7; float x=2.5,y=4.7; printf("%f\n",x+a%3*(int)(x+y)%2/4); } (2)main() { int a=2,b=3; float x=3.5,y=2.5; printf("%f\n",(float)(a+b)/2+(int)x%(int)y); 第三章第三章第三章第三章 順序結構程序設計順序結構程序設計順序結構程序設計順序結構程序設計 一 選擇題 A C D C C 二 操作題 1. x=3,a=2,b=3 2. z=12.700000 3. 1 2 1 a 2 1 2 三三三三....編程題 編程題編程題編程題編程題 1. 某工種按小時計算工資,每月勞動時間(小時)×每小時工資=總工資,總工資中扣除10%公積金,剩餘的為應發工資。編寫一個程序從鍵盤輸入勞動時間和每小時工資,列印出應發工資。 解: #include <stdio.h> main() { float sj,gz,yfgz; printf("time,salary:"); scanf("%f,%f",&sj,&gz); yfgz=sj*gz*0.9; printf("total salary:%f\n",yfgz); } 本程序運行結果為: time,salary:4,3<CR> total salary:10.800000 2.編寫一個程序求出任意一個輸入字元的ASCII碼 解: #include <stdio.h> main() { char c; printf("Input a string:"); scanf("%c",&c); printf("%c ASCII is %d\n",c,c); } 本程序運行結果為: Input a string:a<CR> a ASCII is 97 3、編寫一個程序用於水果店售貨員算帳:已知蘋果每斤2.50元,鴨梨每斤1.80元,香蕉每斤2元,橘子每斤1.6元,要求輸入各類水果的重量,列印出應付第四章第四章第四章第四章 選擇結構程序設計選擇結構程序設計選擇結構程序設計選擇結構程序設計 一、略 二、B B A B C B A 三、1. 1 0 2. 2 3 2 2 3. 10 20 0 4. ch>=』A』&&ch<=』Z』||ch>=』a』&&ch<=』z』 ch>=』0』&&ch<=』9』 ch==』 』 5. -1 四、上機操作 1. 從鍵盤輸入一個英文字母,如果是大寫字母,則將它變為小寫字母輸出;如果是小寫字母,則將其變為大寫字母輸出。 #include<stdio.h> main() {char ch; ch=getchar(); if(ch>='A'&&ch<='Z') ch+=32; else if(ch>='a'&&ch<='z') ch-=32; putchar(ch); putchar('\n'); } 2. 根據輸入的x值依據下列表達式,計算y的值。 2x (x>-1) y = 3 (x=-1) 4+x (x<-1) 解: main() { float x,y; scanf("%f",&x); if(x>-1) y=2*x; else if(x==1) y=3; else y=4+x; printf("y=%f",y); } 本程序運行結果為: -2<CR> y=2.000000 3.編寫程序,輸入一個整數,判斷它是奇數還是偶數,若是奇數,輸出「Is Odd「;若是偶數,輸出「Is Even「。 main() { int x; scanf("%d",&x); if(x%2==0) printf("Is Even\n"); else printf("Is Odd\n"); } 4.設計應用程序,求二次方程ax2+bx+c=0的解。 #include<math.h> main() { float a,b,c,disc,x1,x2,p,q; scanf("%f,%f,%f",&a,&b,&c); if(fabs(a)<=1e-6) printf(" The equation is not a quadratic\n"); else { disc=b*b-4*a*c; if(fabs(disc)< 1e-6) printf("x1=x2=%8.4f\n",-b/(2*a)); else if(disc>1e-6) {x1=(-b+sqrt(disc)/(2*a)); x2=(-b-sqrt(disc)/(2*a)); printf("x1=%8.4f,x2=%8.4f\n",x1,x2); } else { p=-b/(2*a); q=sqrt(-disc/(2*a)); printf("%8.4f+%x8.4fi\n",p,q); printf("%8.4f-%8.4fi\n",p,q);} } } 5555....按托運規則,行李不超過50公斤時,運費為0.15元/公斤,如超過50公斤,超過部分的運費為0.22元/公斤,現有行李w公斤,編寫一個程序計算運費。 解: #include <stdio.h> main() { float w,f,x; printf("weight:"); scanf("%f",&w); if(w<=50) x=0.15*w; else x=0.15*50+0.22*(w-50); printf("money:%6.2f yuan\n",x); } 本程序運行結果為: weight:20<CR> money:3.00 yuan weight:60<CR> money:9.70 yuan 6. 某商場給與顧客購物的折扣率如下: 購物金額<200元 不打折 500元>購物金額>=200元 9折 1000元>購物金額>=500元 8折 購物金額>=1000元 7.5折 輸入一個購物金額,輸出打折率、購物實際付款金額。 #include<stdio.h> main() { float x,y,realx; scanf("%f",&x); if(x<=0) { printf("Error! You input a worry number!\n"); y=0;} else { if(x<200) y=1.0; else if(x<500) y=0.9; else if(x<1000) y=0.8; else y=0.75;} if(y!=0) {realx=x*y; printf("y=%f, the realx=%5.2f\n", y,realx);} } 第五章第五章第五章第五章 循環結構程序設計循環結構程序設計循環結構程序設計循環結構程序設計 一、選擇題 C C A A D D第六章第六章第六章第六章 數組數組數組數組 、選擇題 D A D A A C C A D 二、程序閱讀題 13 13 13 13 13 13第七章第七章第七章第七章 函數函數函數函數 一、選擇題 B D C B B D A A D第第第第8888章章章章 指針指針指針指針 一、選擇題 D A C C(D) D C D 二、填空題 1. m 2. 指針數組名 3. ABCDCD 4.49 5. 25

⑤ 程序設計基礎 C語言習題答案

1、

10,12,a
i=2
E

2、

#include<stdio.h>
main()
{
intn,sum=0;
scanf("%d",&n);
while(n!=0){
sum=sum+n%10;
n=n/10;
}
printf("sum=%d",sum);
}

3、

#include<stdio.h>
intmain()
{
intup=0,low=0;
chararray[100]={0};
gets(array);
for(inti=0;i<100;i++){
if(array[i]>='a'&&array[i]<='z'){
up++;
}elseif(array[i]>='A'&&array[i]<='Z'){
low++;
}
}
printf("大寫字母個數:%d,小寫字母個數:%d",up,low);
return0;
}

4、

#include<stdio.h>
intmain()
{
floatscore[10]={0};
floatsum=0;
intpass=0;
floatave=0;
for(inti=0;i<10;i++){
scanf("%g",&score[i]);
sum+=score[i];
if(score[i]>=60){
pass++;
}
}
ave=sum/10.0;
printf("平均分%g ",sum/10.0);
printf("及格人數%d ",pass);
printf("高於平均分的分數: ");
for(inti=0;i<10;i++){
if(score[i]>=ave){
printf("%g ",score[i]);
}
}
return0;
}

⑥ c語言程序設計(何欽銘 顏暉 第三版)課後習題答案

習 題 1

1.1 填空題

1.函數

2.主函數main();主函數main()

3.主函數main()

4.函數首部;函數體

5.{;}

6.順序結構;選擇結構;循環結構

7..c;.obj;.exe

1.2 思考題

1.答:結構化程序設計是指,為使程序具有一個合理的結構以保證程序正確性而規定的一套如何進行程序設計的原則。順序結構,選擇結構,循環結構

2.答:演算法舉賀亮是對具體問題求解步驟的一

⑦ 跪求《C語言程序設計》課本習題答案!!!

習題1參考答案
一、選擇題 1. A 2. D
二、填空題
1. BASIC、FORTRAN、AL_GOL60和COBOL 2. 8
3. 關鍵字
4. 編輯、編譯、鏈接和運行
三、簡答題 1.答:
(1)C語言具有結構化的控制語句。C語言提供了結構化程序所必需的基本控制語句,實現了對邏輯流的有效控制。
(2)C語言具有豐富的數據結構類型。C語言除提供整型、實型、字元型等基本數據類型外,還提供了用基本數據類型構造出的各種復雜的數據結構,如數組、結構、聯合等。C語言還提供了與地址密切相關的指針類型。此外,用戶還可以根據需要自定義數據類型。 (3)C語言具有豐富的運算符。C語言提供了多達34種運算符,豐富的數據類型與豐富的運算符相結合,使C語言的表達力更具靈活性,同時也提高了執行效率。
(4)C語言簡潔、緊湊,使用方便、靈活,程序書寫自由,有9種控制語句。
(5)C語言既具有高級語言的功能,又具有低級語言的許多功能,通常被稱為中級計算機語言。它既是成功的系統描述語言,又是通用的程序設計語言。 (6)C語言與匯編語言相比,可移植性好。
(7)功能強大。C語言具有低級語言的一些功能,所以,生成目標代碼質量高,程序執行效率高。現在許多系統軟體都用C語言來描述,可以大大提高了編程效率。
2.答:運行一個C語言程序,一般需要經過如下幾個步驟:①上機輸入並編輯源程序;②編譯源程序;③與庫函數連接;④生成可執行目標程序;⑤運行目標程序。 3.答:
(1)操作系統的設計與實現。C語言是一種應用非常廣泛的結構化高級程序設計語言,既適合編寫應用軟體,又適合編寫系統軟體。

⑧ C語言程序設計 中國鐵道出版社的 課後習題答案

一.
1.錯(鏈表可以不是)
2.錯(順序適合查找較多的數據結構,鏈表適合插入刪除較多的數據結構)
3.錯(有可能連續)
4.錯(int a[2][3]中,元素為整型)
5.對.
二.
1.B
2.C
三.
1.D
2.D
3.C(這里是要找到長度為m的鏈表的尾節點)
四.
1.S1語句是讓p指向尾節點(因為while退出的條件是p->next,說明此時p->next為空)
2.S2語句是在鏈表尾插入q(p->next=q),並讓q成為鏈表尾節點(q->next=NULL)
3.(a1,a2,a3,...an,q)
(注,這里的L是不帶頭節點的單鏈表,故第一個節點就是該元素的第一個節點)
另外,虛機團上產品團購,超級便宜

熱點內容
哪些車有配置前後防撞鋼梁 發布:2025-03-16 22:55:35 瀏覽:727
伺服器怎麼設置外網訪問 發布:2025-03-16 22:53:03 瀏覽:184
安卓手機如何繞過緩存軟體 發布:2025-03-16 22:35:16 瀏覽:241
c語言求職 發布:2025-03-16 22:34:23 瀏覽:429
在線教育培訓源碼 發布:2025-03-16 22:31:57 瀏覽:233
反編譯vb工具 發布:2025-03-16 22:27:04 瀏覽:353
安卓流程為什麼越來越多 發布:2025-03-16 22:26:50 瀏覽:933
五軸編程模型 發布:2025-03-16 22:17:48 瀏覽:181
linuxc函數庫 發布:2025-03-16 22:03:33 瀏覽:921
iphone最新版系統從哪裡改密碼 發布:2025-03-16 21:56:19 瀏覽:596