當前位置:首頁 » 編程語言 » mooc北京化工大學c語言編程
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

mooc北京化工大學c語言編程

發布時間: 2022-08-07 03:36:26

c語言編程問題:從鍵盤輸入n個學生某門課的成績,按要求完成功能。

#include<stdio.h>

voidsort(inta[],intn);
voidfailingGrade(inta[],intn);
voidmax_and_min(inta[],intn);

intmain()
{
intscore[10],tmp;
inti,n;
i=n=0;
while(1)
{
scanf("%d",&tmp);
if(tmp<0)
break;
elseif(tmp>100)
continue;
else
{
score[i]=tmp;
i++;
n++;
}
}
if(n>10)
n=10;
sort(score,n);
for(i=0;i<n;i++)
printf("%d",score[i]);
printf(" ");
failingGrade(score,n);
max_and_min(score,n);
return0;
}

//按成績從高到低排序
voidsort(inta[],intn)
{
inti,j;//j表示趟數,i表示每i趟兩兩比較的次數
inttmp;//臨時變數
for(j=0;j<n-1;j++)
for(i=0;i<n-1-j;i++)
{
if(a[i]<a[i+1])
{
tmp=a[i];
a[i]=a[i+1];
a[i+1]=tmp;
}
}
}

voidfailingGrade(inta[],intn)
{
inti,count;
for(i=0,count=0;i<n;i++)
{
if(a[i]<60)
{
count++;
printf("%d",a[i]);
}
}
printf("%d ",count);
}

voidmax_and_min(inta[],intn)
{
intmax,min,i;
max=min=a[0];
for(i=1;i<n;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("%d%d ",max,min);
}

㈡ 我對編程一無所知,想學C語言,哪位好先生給我推薦本適合我的書!非常感謝!

我給你推薦一本《C prime plus(第6版)》,C prime plus這本書是非常經典的C語言入門書籍,現在已經出到第6版了,對你學習C語言是個很不錯的教材選擇。

㈢ 中國大學moocC語言進階里的一道題

#include<stdio.h>charinput1[100];//必須開全局變數!不然會有意外情況。charinput2[100];intmain(){
charch;
longl1=0;
longl2=0;
while((ch=getchar())!=' '){//有空格字元的輸入
input1[l1++]=ch;
}
while((ch=getchar())!=' '){
input2[l2++]=ch;
}
intflag=0;
for(inti=0;i<l2;i++){
for(inth=0;h<l1;h++){
if(input1[h]!=input2[i+h]){
break;
}
if(h==l1-1){
printf("%d",i);
flag=1;
}
}
}
if(!flag){
printf("-1");
}
return0;
}

㈣ C語言上機考 試卷 北京化工大學 有答案嗎

答案肯定是有的,不過還沒考你就得答案了,這個有點。。。

㈤ C語言怎麼編寫一個程序:每次讀入一個正三位數,然後輸出逆序的數字。

#include<stdio.h>

intmain(){
intn;
while(scanf("%d",&n)!=EOF){
intgewei=n%10;//n對10取模,意思就是n除以10的余數,那肯定就是個位上的數字
n=n/10;//然後n除以10,按照整型int運算規則,舍棄了小數部分,所以原來的三位數變成兩位數
intshiwei=n%10;
n=n/10;
intwei=n;
printf("%d%d%d ",gewei,shiwei,wei);
}
return0;
}

要稍微思考一下

㈥ 中國大學moocc語言程序設計蘇小紅課程實驗題為什麼總是顯示結果錯誤

#include <stdio.h>
main()
{
char sex,sports,diet;
float faHeight,moHeight,yourHeight;
printf("sex F or M: , fatherHeight and motherHeight: ,
Whether like sports Y or N: , Whether have good diet Y or N:\n");
scanf("%c,%f,%f,%c,%c",sex,faHeight,moHeight,sports,diet);
if (sex=='F'){
if (sports=='Y'){
if (diet=='Y'){
yourHeight=(faHeight*0.923+moHeight)*0.54*1.02*1.15;
}
else{
yourHeight=(faHeight*0.923+moHeight)*0.54*1.02;
}
}
else{
if (diet=='Y'){
yourHeight=(faHeight*0.923+moHeight)*0.54*1.15;
}
else{
yourHeight=(faHeight*0.923+moHeight)*0.54;
}
}
}
else {
if (sports=='Y'){
if (diet=='Y'){
yourHeight=(faHeight+moHeight)*0.5*1.02*1.15;
}
else{
yourHeight=(faHeight+moHeight)*0.5*1.02;
}
}
else{
if (diet=='Y'){
yourHeight=(faHeight+moHeight)*0.5*1.15;
}
else{
yourHeight=(faHeight+moHeight)*0.5;
yourHeight=(faHeight+moHeight)*0.5;
}
}
}
printf("yourHeight is %f cm",yourHeight);
}

㈦ mooc《C語言程序設計》- 翁愷 已經不可以觀看了,求視頻觀看或者下載地址

《06 00上海交通大學 計算機自考考研課程 C語言程序設計基礎 全27講 視頻教程》網路網盤資源免費下載

鏈接:https://pan..com/s/1scbJKnr2dLqm5KdwwimJYQ

?pwd=ks7d 提取碼:ks7d

06 00上海交通大學 計算機自考考研課程 C語言程序設計基礎 全27講 視頻教程|各學科 學習視頻目錄|03.avi|02.avi|01.avi|政治目錄.txt|哲學目錄.txt|語言目錄.txt|藝術目錄.txt|醫學目錄.txt|心理目錄.txt|物理目錄.txt|文學目錄.txt|體育目錄.txt|數學目錄.txt