日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言改错和填空能运行吗,C语言改错填空编程

發(fā)布時間:2025/3/11 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言改错和填空能运行吗,C语言改错填空编程 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

改錯題

1、在考生文件夾下,給定程序MODI.C的功能是:

從低位開始取出長整型變量s中奇數(shù)位上的數(shù),依次構(gòu)成一個新數(shù)放在t中。例如,當s中的數(shù)為:7654321時,t中的數(shù)為:7531。

請修改并運行該程序,然后將源程序文件MODI.C上傳。

#include

#include

main( )

{ long s, t, sl=10;

clrscr();

printf("\nPlease enter s:");

scanf("%ld", &s);

/************found************/

t = s / 10; s%10 改為 t=s%10;

while ( s > 0)

{ s = s/100;

t = s%10 * sl + t;

/************found************/

sl = sl*100 ;改為 S1=S1*10;

}

printf("The result is: %ld\n", t);

}

2、在考生文件夾下,給定程序MODI.C的功能是:

求一維數(shù)組a中的值為偶數(shù)的元素之和。例如,當一維數(shù)組a中的元素為:10,4,2,7,3,12,5,34,5,9 ,

程序的輸出應為:The result is: 62

#include

#include

main()

{ int a[10]={10,4,2,7,3,12,5,34,5,9},i,s;

clrscr();

s = 0;

for ( i=0; i<10; i++)

/************found************/

if (i % 2 == 0) 改為if (a[i] % 2 == 0)

s = s + a[i];

/************found************/

print("The result is: %d\n", s);

}

3、在考生文件夾下,給定程序MODI.C的功能是:

求一維數(shù)組a中值為偶數(shù)的元素之和。

例如,當一維數(shù)組a中的元素為:10,4,2,7,3,12,5,34,5,9 ,

程序的輸出應為:The result is: 62。

#include

#include

sum ( int arr[ ],int n )

{ int i,s;

clrscr();

s = 0;

for ( i=0; i

if (arr[i] % 2 == 0)

/************found************/

s = s + i; 改為s = s + [i];

return (s);

}

main()

{ int a[10]={10,4,2,7,3,12,5,34,5,9},i,s;

/************found************/

s = sum( a ,2 ); 改為s = sum( a ,10);

printf("The result is: %d\n", s);

}

4、在考生文件夾下,給定程序MODI.C的功能是:

求二維數(shù)組a中的最大值。

例如,當二維數(shù)組a中的元素為:

4 4 34

7 3 12

5 6 5

程序的輸出應為:The max is: 34 。

#include

#include

main()

{ int a[3][3]={4,4,34,7,3,12,5,6,5},i,j,max;

clrscr();

max = a[0][0];

for ( i=0; i<3; i++)

for ( j=0; j<3; j++)

/************found************/

if (max > a[i][j])

{

/************found************/

max == a[i][j];

}

printf("The max is: %d\n", max);

}

5、在考生文件夾下,給定程序MODI.C的功能是:

求一維數(shù)組a中的最大元素及其下標。

例如,當一維數(shù)組a中的元素為:1,4,2,7,3,12,5,34,5,9,

程序的輸出應為:The max is: 34,p

os is: 7 。

#include

#include

main()

{ int a[10]={1,4,2,7,3,12,5,34,5,9},i,max,pos;

clrscr();

max = a[0];

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的c语言改错和填空能运行吗,C语言改错填空编程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。