C語(yǔ)言專(zhuān)項(xiàng)4程序設(shè)計(jì)題100道_第1頁(yè)
C語(yǔ)言專(zhuān)項(xiàng)4程序設(shè)計(jì)題100道_第2頁(yè)
C語(yǔ)言專(zhuān)項(xiàng)4程序設(shè)計(jì)題100道_第3頁(yè)
C語(yǔ)言專(zhuān)項(xiàng)4程序設(shè)計(jì)題100道_第4頁(yè)
C語(yǔ)言專(zhuān)項(xiàng)4程序設(shè)計(jì)題100道_第5頁(yè)
已閱讀5頁(yè),還剩50頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、專(zhuān)項(xiàng)4程序設(shè)計(jì)題100道1. Program.c/*【程序設(shè)計(jì)】功能:在鍵盤(pán)上輸入一個(gè)3行3列矩陣的各個(gè)元素的值(值為整數(shù)),然后輸出主對(duì)角線(xiàn)元素的 平方和,并在fun()函數(shù)中輸出。*/#include "stdio.h"main()int i,j,s,a33;int fun(int a33);void TestFunc();for(i=0;i<3;i+)for(j=0;j<3;j+) scanf("%d”,&aij);s=fun(a);printf("Sum=%dn",s);TestFunc();int fun(int

2、a33)/* & cc ;* /void TestFunc()FILE *IN,*OUT;int m;int n;int i33;int o;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Write File Error");for(m=0;m<3;m+)for(n=0;n<3;n+)fscan

3、f(IN,"%d",&imn);o=fun(i);fprintf(OUT,"%dn",o);fclose(IN);fclose(OUT);in.DAT1 2 3 4 5 6 7 8 92./*【程序設(shè)計(jì)】/* End *功能:從鍵盤(pán)輸入一個(gè)大于 3的整數(shù),調(diào)用 函數(shù)fun判斷其是否素?cái)?shù),然后在 main函數(shù)中輸出相應(yīng)的結(jié)論信息。例如:7是素?cái)?shù),8不是素?cái)?shù)。請(qǐng)編寫(xiě) fun 函數(shù)。素?cái)?shù)是僅能被1和自身整除的數(shù)。*/#include "stdio.h"int fun(int n)/* & cc ;* /* End */voi

4、d TestFunc()FILE *IN,*OUT;int iIN,iOUT,i;IN=fopen("5.in","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("5.out","w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed");for(i=0;i<1

5、0;i+)fscanf(IN,"%d",&iIN);iOUT=fun(iIN);fprintf(OUT,"%dn",iOUT);fclose(IN);fclose(OUT);main()int m,flag;printf("input an integer:");scanf("%d",&m);flag=fun(m);if(flag)printf("%d is a prime.n",m);elseprintf("%d is not a prime.n",m);T

6、estFunc();5.in8 4214567 23457 134153 534269 2155479379 371 159 4563 5469 2373. Program.c/*【程序設(shè)計(jì)】功能:求出二維數(shù)組外圍元素之和,作為函 數(shù)值返回。二維數(shù)組的值在主函數(shù)中賦予。*/#define M 4#define N 5#include "stdio.h"int fun(int aMN)/*; C* /* End *void TestFunc()FILE *IN,*OUT;int iINMN,iOUT;int i,j,k;IN=fopen("14.in",&

7、quot;r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("14.out","w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed");for(k=0;k<10;k+) for(i=0;i<M;i+)for(j=0;j<N;j+)fscanf(IN,"%d",

8、&iINij);iOUT=fun(iIN);fprintf(OUT,"%dn",iOUT);fclose(IN);fclose(OUT);main()intaMN=1,3,5,7,9,246,8,10,234,5,6,4 ,5,6,7,8;int y;y=fun(a);printf("s=%dn",y);TestFunc();14.in1 3 5 7 9 2 4 6 8 10 2 3 4 5 6 4 5 6 7 8 1 3 4 3 523 43 5 25 43 54 5 43 54 23 4 5 53 4 5 6 4 5 6 7 832 4 32

9、 43 432 23 5 6 65 67 5 6 5 6 8 87 78 8787 8 87 67 6 6 5 44 6 76 5 45 4 3 65 89 89 987 65 45 4545 53 535 543 3 3 4 5 5 35 43 543 54 35 43 545 4 5 45 4 535 43 5 43 5 43 543 5 435 43 543543 44 6 765 45 4 3 65 89 89 98 7 43 3 3 4 5 5 35 43 54354 35 43 5 45 44. Program.c/*【程序設(shè)計(jì)】功能:求給定正整數(shù) m以?xún)?nèi)的素?cái)?shù)之和。例如:當(dāng)m=2

10、0時(shí),函數(shù)值為77。*/#include "stdio.h" int fun(int m) /*Begin*/*End*/main()int y;void TestFunc();y=fun(20);printf("y=%dn",y);TestFunc();void TestFunc()FILE *IN,*OUT;int iIN,iOUT,i;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be

11、Changed");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed");for(i=0;i<5;i+)fscanf(IN,"%d",&iIN);iOUT=fun(iIN);fprintf(OUT,"%dn",iOUT);fclose(IN);fclose(OUT);in.dat10203040505. Program.c/*【程序設(shè)計(jì)

12、】 功能:求n階方陣主、副對(duì)角線(xiàn)上的元素之 積。*/#define N 4#include "stdlib.h"#include "stdio.h" float mul(int arr口N)/*Begin*/*End */main()int aNN,i,j;void TestFunc();for(i=0;i<N;i+)for(j=0;j<N;j+)aij=rand()%10;for(i=0;i<N;i+)for(j=0;j<N;j+)printf("%4d",aij);printf("n")

13、;printf("The sum is %dn",mul(a);TestFunc();void TestFunc()FILE *IN,*OUT;int m,n;int i44;float o;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error");OUT=fopen("out.dat","w"); if(OUT=NULL) printf("Write File Error");for(m=0;

14、m<100;m+)for(n=0;n<100;n+)fscanf(IN,"%d",&imn);o=mul(i);fprintf(OUT,"%fn",o);fclose(IN);fclose(OUT);6./*【程序設(shè)計(jì)】功能:從低位開(kāi)始取出長(zhǎng)整型變量s中偶數(shù)位上的數(shù),依次構(gòu)成一個(gè)新數(shù)放在t中。例如:當(dāng)s中的數(shù)為:7654321時(shí),t中的數(shù) 為:642。*/#include "stdio.h long fun (long s,long t) /*Begin*/* End */return t;main()long s, t,m

15、;void TestFunc();printf("nPlease enter s:"); scanf("%ld", &s); m=fun(s,t);printf("The result is: %ldn", m);TestFunc();void TestFunc()FILE *IN,*OUT;int n;long i,t,m;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error");OUT=fopen(&q

16、uot;out.dat","w");if(OUT=NULL)printf("Write File Error");for(n=0;n<5;n+)fscanf(IN,"%ld",&i);m=fun(i,t);fprintf(OUT,"%ld'n",m);fclose(IN);fclose(OUT);7./*【程序設(shè)計(jì)】功能:計(jì)算并輸出給定整數(shù) n的所有因子之 和(不包括1與自身)。注意:n的值不大于1000。例如:n的值為855時(shí),應(yīng)輸出704。*/#include "std

17、io.hint fun(int n)8./*【程序設(shè)計(jì)】/*Begin*/功能:編寫(xiě)函數(shù)fun其功能是:根據(jù)整型形參m,計(jì)算如下公式的值:y=1 + 1/3+ 1/5+ 1/7+ +1/(2m+1)例如:若 m=9,則應(yīng)輸出:2.133256/* End */void TestFunc()FILE *IN,*OUT;int iIN,iOUT,i;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT

18、=fopen("out.dat","w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed");for(i=0;i<5;i+)fscanf(IN,"%d",&iIN);iOUT=fun(iIN);fprintf(OUT,"%dn",iOUT);fclose(IN);fclose(OUT);main()printf("s=%dn",fun(855);TestFunc();*/

19、#include "stdio.h double fun(int m)/*Begin*/* End */main()int n;void TestFunc();printf("Enter n:");scanf("%d", &n);printf("nThe result is %1fn", fun(n);TestFunc();void TestFunc()FILE *IN,*OUT;int i ;int t;double o;IN=fopen("in.dat","r");if(I

20、N=NULL)printf("Read File Error");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Write File Error");for(i=0;i<5;i+)fscanf(IN,"%d",&t);o=fun;fprintf(OUT,"%lfn",o);fclose(IN);fclose(OUT);9./*【程序設(shè)計(jì)】完成函數(shù)int fun(int m)判斷m是否為素?cái)?shù),如果是素?cái)?shù)函數(shù)輸出1,否則輸

21、出0。主函數(shù)調(diào)用時(shí),m是素?cái)?shù)顯示"yes"不是素?cái)?shù)顯示"no"。*/#include "stdio.h" int fun( int m) /*Begin*/void main()int m,i,a10;FILE *IN,*OUT;printf("請(qǐng)輸入m的值:"); scanf("%d",&m);if(fun(m)printf("yesn");elseprintf("non");IN=fopen("in.dat","r

22、");if(IN=NULL)printf("輸入文件打開(kāi)失??!”); return;OUT=fopen("out.dat","w");if(OUT=NULL)printf("輸出文件打開(kāi)失敗!"); return;for(i=0;i<10;i+)fscanf(IN,"%d",&ai);fprintf(OUT,"%dn",fun(ai);fclose(IN);fclose(OUT);10./*【程序設(shè)計(jì)】*End*/功能:編寫(xiě)一個(gè)函數(shù),該函數(shù)可以統(tǒng)計(jì)一個(gè) 長(zhǎng)度為2

23、的字符/*End*/串在另一個(gè)字符串中出現(xiàn)的次數(shù)。例如:假定輸入的字符串為asdasasdfgasdaszx67asdmklq字符串為:as則應(yīng)出6。*/#include "stdio.h"#include "string.h#include "conio.h int fun(char *str,char *substr)/*Begin*/char i200;char o200;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error")

24、;OUT=fopen("out.dat","w");if(OUT=NULL)printf("Write File Error");fscanf(IN,"%s",i);n=fun(i,"as");fprintf(OUT,"%d",n);fclose(IN);fclose(OUT);11./*【程序設(shè)計(jì)】main()char str81,substr3;void TestFunc();int n;printf("輸入主字符串:");gets(str);prin

25、tf("輸入子字符串:");gets(substr);puts(str);puts(substr);n=fun(str,substr);printf("n=%d'n",n);TestFunc();功能:用函數(shù)求N個(gè)10,60上的整數(shù)中能被5整除的最大的數(shù),如存在則返回這個(gè)最大值,如 果不存在則返回0。*/#include "stdio.h"#define N 30#include "stdlib.h" int find(int arr,int n)int m=0;/*Begin*/void TestFunc

26、() FILE *IN,*OUT; int n;/*return(m);End*/main()int aN,i,k;void TestFunc();for(i=0;i<N;i+)ai=rand()%50+10;for(i=0;i<N;i+)printf("%5d",ai);if(i+1)%5=0) printf("n");k=find(a,N);if(k=0)printf("NO FOUND'n");elseprintf("the max is:%d'n",k); TestFunc();

27、void TestFunc()FILE *IN,*OUT;int n;int i5;int o;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Write File Error");for(n=0;n<5;n+)fscanf(IN,"%d",&in);o=find(i,5);fpri

28、ntf(OUT,"%dn",o);fclose(IN);fclose(OUT);12./*【程序設(shè)計(jì)】功能:編寫(xiě)程序,實(shí)現(xiàn)矩陣(3行3歹U)的 轉(zhuǎn)置(即行列互換)例如:輸入下面的矩陣:100 200 300400 500 600700 800 900程序輸出:100 400 700200 500 800300 600 900*/#include "stdio.hvoid fun(int array33)/*Begin*/*End */main()int i,j;void NONO();int array33=100,200,300, 400,500,600, 70

29、0,800,900;for (i=0; i < 3; i+)功能:將主函數(shù)中輸入的字符串反序存放。例如:輸入字符串"abcdefg”,則應(yīng)輸出"gfedcba"。/*End */for (j=0; j < 3; j+) printf("%7d",arrayij);printf("n");fun(array);printf("Converted array:n");for (i=0; i < 3; i+)for (j=0; j < 3; j+) printf("%7d&qu

30、ot;,arrayij);printf("n");NONO();void NONO()int i,j, array33;FILE *rf, *wf ;rf = fopen("in.dat", "r");wf = fopen("out.dat", "w");for (i=0; i < 3; i+)for (j=0; j < 3; j+)fscanf(rf, "%d", &arrayij);fun(array);for (i=0; i < 3; i+)f

31、or (j=0; j < 3; j+)fprintf(wf, "%7d", arrayij); fprintf(wf, "n");fclose(rf);fclose(wf);13./*【程序設(shè)計(jì)】*/#include "stdio.h"#include "string.h"#include "conio.h"#define N 81 void fun(char *str,int n) /*Begin*/TestFunc()FILE *IN,*OUT;char sIN20,*sOUT;int

32、 iLENGTH;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed");fscanf(IN,"%s",sIN);iLENGTH=strl

33、en(sIN);sOUT=sIN;fun(sIN,iLENGTH);fprintf(OUT,"%sn",sOUT);fclose(IN);fclose(OUT);main()char s N;int l;printf("input a string:");gets(s);l=strlen(s);fun(s,l);printf("The new string is :");puts(s);TestFunc();14.#include <stdio.h>/*【程序設(shè)計(jì)】題目:用while語(yǔ)句求1100的累計(jì)和。*/ int f

34、un(int n) /*Begin*/*End*/void main()int sum = 0;sum=fun(100);printf ("sum = %dn", sum);TestFunc();TestFunc()FILE *IN,*OUT;int i;int iIN,iOUT;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("out.dat&qu

35、ot;,"w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed");for(i=0;i<5;i+)fscanf(IN,"%d",&iIN);iOUT=fun(iIN);fprintf(OUT,"%dn",iOUT);fclose(IN);fclose(OUT);15./*【程序設(shè)計(jì)】計(jì)算1+1/2+1/3+-+1/n并輸出結(jié)果*/#include "stdio.h" float fun( i

36、nt n) /*Begin*/* End */void main()int m,i,a10;FILE *IN,*OUT;printf("請(qǐng)輸入n的值:"); scanf("%d",&m);printf("fun=%fn",fun(m);IN=fopen("in.dat","r");if(IN=NULL)printf("輸入文件才T開(kāi)失??!"); return;OUT=fopen("out.dat","w");if(OUT=NUL

37、L)printf("輸出文件才T開(kāi)失敗!"); return;for(i=0;i<10;i+)fscanf(IN,"%d",&ai);fprintf(OUT,"%fn",fun(ai);fclose(IN);fclose(OUT);16./*【程序設(shè)計(jì)】符,并統(tǒng)計(jì)新生成串中包含的字母?jìng)€(gè)數(shù)。例如:輸入的字符串為ab234$df4,新生成的串為abdf 。*/#include "stdio.h"#include "conio.h#define N 80 main()char strN;int f

38、un(char *ptr);void TestFunc();int s;printf("input a string:");gets(str);printf("The original string is :"); puts(str);s=fun(str);printf("The new string is :");puts(str);printf("There are %d char in the new string.",s);TestFunc(); int fun(char *ptr)/*End */*Beg

39、in*/功能:輸入一個(gè)字符串,過(guò)濾此串,只保留 串中的字母字void TestFunc()FILE *IN,*OUT;char sINN;int iOUT;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Please Verify The Current Dir

40、. It May Be Changed");fscanf(IN,"%s",sIN);iOUT=fun(sIN);fprintf(OUT,"%d %sn",iOUT,sIN);fclose(IN);fclose(OUT);17./*【程序設(shè)計(jì)】求所有的1到自然數(shù)n中,個(gè)位數(shù)是6,且 能被3整除的數(shù)之和。*/#include "stdio.h"int fun( int n)/* & cc ;* /int n,s=0,i,a10;FILE *IN,*OUT;printf("請(qǐng)輸入n的值:"); scan

41、f("%d",&n);printf("s=%dn",fun(n);IN=fopen("in.dat","r");if(IN=NULL)printf("輸入文件打開(kāi)失?。 ?; return;OUT=fopen("out.dat","w");if(OUT=NULL)printf("輸出文件打開(kāi)失敗!"); return;for(i=0;i<10;i+)fscanf(IN,"%d",&ai);fprintf(

42、OUT,"%dn",fun(ai);fclose(IN);fclose(OUT);18./*【程序設(shè)計(jì)】/* End *void main()功能:從低位開(kāi)始取出長(zhǎng)整型變量s奇數(shù)位上的數(shù),依次構(gòu)成一個(gè)新數(shù)放在t中。例如:當(dāng)s中的數(shù)為:7654321時(shí),t中的數(shù) 為:7531。*/#include "stdio.h"fprintf(OUT,"%ld'n",m);fclose(IN);fclose(OUT);long fun (long s,long t)/*Begin*/19./*【程序設(shè)計(jì)】End */*return t; m

43、ain()long s, t,m;void TestFunc();printf("nPlease enter s:"); scanf("%ld", &s);m=fun(s,t);printf("The result is: %ld'n", m);TestFunc();功能:給定n個(gè)數(shù)據(jù),求最小值出現(xiàn)的下標(biāo) 位置(如果最小值出現(xiàn)多次,求出第一次出現(xiàn)的位置即 可)。*/#include "stdio.h" int station(int s,int n)/*Begin*/*End */void Test

44、Func()FILE *IN,*OUT;int n;long i,t,m;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error");OUT=fopen("out.dat","w"); if(OUT=NULL)printf("Write File Error");for(n=0;n<5;n+)fscanf(IN,"%ld",&i);m=fun(i,t);main()int a100,

45、n,i,t;void TestFunc();scanf("%d",&n);for(i=0;i<n;i+)scanf("%d”,&ai);t=station(a,n);printf("the min_value position is:%dn",t);TestFunc();void TestFunc()FILE *IN,*OUT;int n;int i10;int o;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Er

46、ror");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Write File Error");for(n=0;n<10;n+)fscanf(IN,"%d",&in);o=station(i,10);fprintf(OUT,"%dn",o);fclose(IN);fclose(OUT);20./*【程序設(shè)計(jì)】 編寫(xiě)函數(shù)int fun(char c),如果c為字母返回1,否則返回0。在主函數(shù)中調(diào)用fun函數(shù),統(tǒng)計(jì)字符串中字 母的個(gè)

47、數(shù)。*/#include "stdio.h" int fun(char c)/*Begin*/* End */void main()int i,j,num=0;char str255;FILE *IN,*OUT;printf("請(qǐng)輸入一彳T字符串:");gets(str);for(i=0;stri!='0'i+)if(fun(stri) num+;printf("字符串中字母的個(gè)數(shù)為: num=%dn",num);IN=fopen("in.dat","r");if(IN=NULL

48、)printf("輸入文件打開(kāi)失?。 ?; return;OUT=fopen("out.dat","w");if(OUT=NULL)printf("輸出文件打開(kāi)失??!"); return;for(j=0;j<10;j+)fscanf(IN,"%s",&str);for(num=0,i=0;stri!='0'i+)if(fun(stri) num+;fprintf(OUT,"%dn",num);fclose(IN);fclose(OUT);21./*【程序設(shè)

49、計(jì)】功能:求5行5列矩陣的主、副對(duì)角線(xiàn)上元素N和。汪后,兩條對(duì)角線(xiàn)相交的元素只加一次。例如:主函數(shù)中給出的矩陣的兩條對(duì)角線(xiàn)的 和為45。*/#include "stdio.h#define M 5int fun(int aMM) /*Begin*/for(j=0;j<M;j+)fscanf(IN,"%d",&iINij);iOUT=fun(iIN);fprintf(OUT,"%dn",iOUT);fclose(IN);fclose(OUT);main()intaMM尸135,7,9,2,4,6,8,10,2,3,4,5,6,4,5

50、,6,7,8,1,3,4,5,6;int y;y=fun(a);printf("s=%dn",y);TestFunc();22./*【程序設(shè)計(jì)】/* End */void TestFunc()FILE *IN,*OUT;int iINMM,iOUT;int i,j;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("out.dat",&quo

51、t;w");if(OUT=NULL)printf("Please Verify The Current Dir. It May Be Changed"); for(i=0;i<M;i+)輸入一行字符,將其中的小寫(xiě)字母轉(zhuǎn)換為大寫(xiě)字母,其余字符不變。完成函數(shù)void fun( char str80),將轉(zhuǎn)換后的字符串仍存入到str中。*/#include "stdio.h" void fun( char str80) /*End*/*Begin*/ void main()char str80;int i;FILE *IN,*OUT;print

52、f("請(qǐng)輸入一行字符串:");gets(str);printf("n字符串轉(zhuǎn)換后為:");fun(str);puts(str);IN=fopen("in.dat","r");if(IN=NULL)printf("輸入文件才T開(kāi)失??!"); return;OUT=fopen("out.dat","w");if(OUT=NULL)printf("輸出文件才T開(kāi)失敗!"); return;for(i=0;i<10;i+)fscanf(I

53、N,"%s",&str);fun(str);fprintf(OUT,"%sn",str);fclose(IN);fclose(OUT);23./*【程序設(shè)計(jì)】功能:對(duì)任意輸入的 x,用下式計(jì)算并輸出 y的值。5x<10y= 0x=10-5x>10*/#include "stdio.h"int fun(int n)/* D /-x z*i n* /* End */main ()int x,y;void TestFunc();printf("enter x:");scanf("%d&quo

54、t;,&x);y=fun(x);printf("x=%d,y=%dn",x,y);TestFunc();void TestFunc()FILE *IN,*OUT;int i;int iIN;long int iOUT;IN=fopen("in.dat","r");if(IN=NULL)printf("Please Verify The Currernt Dir.It May Be Changed");OUT=fopen("out.dat","w");if(OUT=NU

55、LL)printf("Please Verify The Current Dir. ItEnd*/功能:產(chǎn)生20個(gè)30,120上的隨機(jī)整數(shù)放入二維數(shù)組a54中,求每行元素的和。May Be Changed");for(i=0;i<5;i+)fscanf(IN,"%d",&iIN);iOUT=fun(iIN);fprintf(OUT,"%ldn",iOUT);fclose(IN);fclose(OUT);24./*【程序設(shè)計(jì)】功能:求一個(gè)n位自然數(shù)的各位數(shù)字的積。(n是小于10的自然數(shù))*/#include "s

56、tdio.h"#include "conio.h long fun(long n)/*Begin*/*main()scanf("%ld", &m);printf("nThe result is %ld'n", fun(m);TestFunc();void TestFunc()FILE *IN,*OUT;int c ;long t;long o;IN=fopen("in.dat","r");if(IN=NULL)printf("Read File Error");OUT=fopen("out.dat","w");if(OUT=NULL)printf("Write File Error");for(c=1;c<=5;c+)fscanf(IN,"%ld",&t);o=fun;fprintf(OUT,"%ld'n",o);fclose(IN);fclose(OUT);25./*【程序設(shè)計(jì)】long m;*/void TestFunc();print

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論