導航:首頁 > 編程語言 > 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語言編程題求助各位大神了相關的資料

熱點內容
python數據學習筆記 瀏覽:748
程序員那麼可愛二十一集預告 瀏覽:53
壓縮機的uvw怎麼接線 瀏覽:631
快速拆分工作表為加密獨立工作表 瀏覽:409
python爬蟲多層div 瀏覽:618
太原市市場監督局app叫什麼 瀏覽:792
加密視頻有什麼用 瀏覽:199
伺服器ip怎麼換域名訪問 瀏覽:40
iphone快捷指令相冊加密 瀏覽:817
數據分析師圖譜python 瀏覽:962
三十六的簡便演算法 瀏覽:845
python影響因子權重 瀏覽:623
鐵皮人下個伺服器什麼時候開 瀏覽:98
pdf解密列印 瀏覽:356
安卓要升級什麼系統 瀏覽:516
什麼壓縮刻錄軟體好用 瀏覽:231
android打包和設置編譯 瀏覽:9
華為伺服器怎麼做熱備份 瀏覽:213
千鋒python語句 瀏覽:780
風水app哪個好用 瀏覽:7