導航:首頁 > 編程語言 > c語言編程題求助各位大神了

c語言編程題求助各位大神了

發布時間:2025-06-16 02:57:56

A. 一道c語言編程題,各位大神幫幫忙啊!

代碼如下:

#include<stdio.h>
#include<stdlib.h>

intmain()
{
intscore=0,sum=0,max=0,min=100,count=0,aver=0;

printf("請輸入學生成績:");

scanf("%d",&score);

while(score>=0&&score<=100){

sum+=score;

if(score>max){
max=score;
}

if(score<min){
min=score;
}

count++;

scanf("%d",&score);
}

printf("共錄入了%d個學生成績。 ",count);
printf("最高分:%d ",max);
printf("最低分:%d ",min);
printf("平均分:%d ",sum/count);

system("pause");
return0;
}

B. 用C語言編寫1ms延遲子程序,不明白for (j=0;j<120;j++),求助大大們

void delay1ms(int x)//延遲函數開始
{
int i,j;
for (i=0;i<x;i++) //計數x次,延遲x 1ms
for (j=0;j<120;j++); //計數120次,延遲1ms
}
這是一個for循環嵌套,每執行一次第一個for語句,那麼第二個for語句要執行120次
for (j=0;j<120;j++); 就是沒執行一次第一個for循環,就令 j =0,再判斷是否 j 滿足循環條件(這里就是判斷是否 j 小於120)如果滿足就繼續循環,如果不滿足就跳出循環。

C. C語言初學編程問題 排序問題!求助 感謝!

#include<stdio.h> //冒泡排序,從小到大。void sort(int a[], int n) { int i, j; int temp; int len = n; for (i = 0; i < len - 1; i++) for (j = 0; j < len - 1 - i; j++){ if (a[j] > a[j + 1]) { temp = a[j]; a[j] = a[j + 1]; a[j+1] = temp; } } } int main() { int a[5] = {2, 3 ,1, 5, 4}; int i; sort(a, 5); for(i = 0; i < 5; i++) { printf("%d ", a[i]); } printf("\n");}

D. 求助各位C語言編程高手~幫我做3道題~

#include<stdio.h>
#include<string.h>

#defineN4

/*-----------------------------------------
第一題
-------------------------------------------*/
voidDiamond(constchar*s,intn,intlen)
{
printf("%*s%-s\n",len,s+n-1,s+n);
if(n>1)
Diamond(s,n-1,len);
printf("%*s%-s\n",len,s+n,n==len?s+n:s+n+1);
}

/*-----------------------------------------
第二題
-------------------------------------------*/
typedefstruct
{
intgcd;
intlcm;
}pair;

voidGCD_LCM(inta,intb,pair*p)
{
inttmp;
intproct=a*b;
while(b%a)
{
tmp=a;
a=b%a;
b=tmp;
}
p->gcd=a;
p->lcm=proct/a;
}

/*-----------------------------------------
第三題
-------------------------------------------*/
voidSwap(int*lhs,int*rhs)
{
inttmp=*lhs;
*lhs=*rhs;
*rhs=tmp;
}

voidBubbleSort(int*beg,int*end)
{
for(;beg!=end;++beg)
for(int*p=end-1;p!=beg;--p)
if(*p<*(p-1))
Swap(p,p-1);
}

voidSelectSort(int*beg,int*end)
{
for(;beg!=end;++beg)
{
int*max=beg;
for(int*p=beg+1;p!=end;++p)
if(*max<*p)
max=p;
Swap(beg,max);
}
}

voidPrint(int*beg,int*end)
{
while(beg!=end)
printf("%d",*beg++);
putchar('\n');
}

intmain()
{
/*一*/
charpt[N+1]={0};
memset(pt,'*',N);
Diamond(pt,N,N);

/*二*/
pairp;
GCD_LCM(3,6,&p);
printf("%d%d\n",p.gcd,p.lcm);

/*三*/
inta[]={32,9,45,22,15,48,47,8,55,1};
Print(a,a+10);
BubbleSort(a,a+10);
Print(a,a+10);
SelectSort(a,a+10);
Print(a,a+10);
}

閱讀全文

與c語言編程題求助各位大神了相關的資料

熱點內容
linux判斷是否為文件 瀏覽:937
手機處理器編譯器 瀏覽:704
ug曲線點倒角編程 瀏覽:928
當演算法把人馴服 瀏覽:710
字母r編程 瀏覽:576
編譯openwrt添加型號 瀏覽:275
快眼看app哪裡下載 瀏覽:11
手機上門禁卡加密怎麼處理 瀏覽:857
2019年稅務師教材pdf 瀏覽:503
android支付寶源碼 瀏覽:942
建造師加密鎖怎麼辦 瀏覽:301
郵箱在線文檔怎麼設文件夾 瀏覽:875
區塊鏈編譯eth 瀏覽:783
安卓手機軟體如何給照片加發光點 瀏覽:979
結構性存款在app哪裡 瀏覽:970
iphone如何快速打開app 瀏覽:800
好玩的程序員笑話 瀏覽:82
linux下如何搭建web伺服器 瀏覽:222
狼群之飢和命令之眼 瀏覽:369
xp使用telnet命令 瀏覽:159