C语言代码大全

上传人:nt****6 文档编号:35396750 上传时间:2018-03-15 格式:DOC 页数:74 大小:306KB
返回 下载 相关 举报
C语言代码大全_第1页
第1页 / 共74页
C语言代码大全_第2页
第2页 / 共74页
C语言代码大全_第3页
第3页 / 共74页
C语言代码大全_第4页
第4页 / 共74页
C语言代码大全_第5页
第5页 / 共74页
点击查看更多>>
资源描述

《C语言代码大全》由会员分享,可在线阅读,更多相关《C语言代码大全(74页珍藏版)》请在金锄头文库上搜索。

1、-摘自 宋鲁生 程序设计大赛乘法口诀表 #include #include void main(void) int i,j,x,y; clrscr(); printf(“nn * * * 乘法口诀表 * * * nn“); x=9; y=5; for(i=1;i void main() char SelectKey,CreditMoney,DebitMoney; while(1) do clrscr(); puts(“=“); puts(“| Please select key: |“); puts(“| 1. Quary |“); puts(“| 2. Credit |“); puts(“|

2、 3. Debit |“); puts(“| 4. Return |“); puts(“=“); SelectKey = getch(); while( SelectKey!=1 switch(SelectKey) case 1: clrscr(); puts(“=“); puts(“| Your balance is $1000. |“); puts(“| Press any key to return. |“); puts(“=“); getch(); break; case 2: do clrscr(); puts(“=“); puts(“| Please select Credit m

3、oney: |“); puts(“| 1. $50 |“); puts(“| 2. $100 |“); puts(“| 3. Return |“); puts(“=“); CreditMoney = getch(); while( CreditMoney!=1 switch(CreditMoney) case 1: clrscr(); puts(“=“); puts(“| Your Credit money is $50,Thank you! |“); puts(“| Press any key to return. |“); puts(“=“); getch(); break; case 2

4、: clrscr(); puts(“=“); puts(“| Your Credit money is $100,Thank you! |“); puts(“| Press any key to return. |“); puts(“=“); getch(); break; case 3: break; break; case 3: do clrscr(); puts(“=“); puts(“| Please select Debit money: |“); puts(“| 1. $50 |“); puts(“| 2. $100 |“); puts(“| 3. $500 |“); puts(“

5、| 4. $1000 |“); puts(“| 5. Return |“); puts(“=“); DebitMoney = getch(); while( DebitMoney!=1 switch(DebitMoney) case 1: clrscr(); puts(“=“); puts(“| Your Debit money is $50,Thank you! |“); puts(“| Press any key to return. |“); puts(“=“); getch();break; case 2: clrscr(); puts(“=“); puts(“| Your Debit

6、 money is $100,Thank you! |“); puts(“| Press any key to return. |“); puts(“=“); getch(); break; case 3: clrscr(); puts(“=“); puts(“| Your Debit money is $500,Thank you! |“); puts(“| Press any key to return. |“); puts(“=“); getch(); break; case 4: clrscr(); puts(“=“); puts(“| Your Debit money is $100

7、0,Thank you! |“); puts(“| Press any key to return. |“); puts(“=“); getch(); break; case 5: break; break; case 4: clrscr(); puts(“=“); puts(“| Thank you for your using! |“); puts(“| Good bye! |“); puts(“=“); return; 模拟 ATM(自动柜员机)界面 #include void main() int Password=0,Number=0,price=58,i=0; while( Pas

8、sword != 1234 ) if( i = 3 ) return; i+; puts(“Please input Password: “); scanf(“%d“, i=0; while( Number!=price ) do puts(“Please input a number between 1 and 100: “); scanf(“%d“, printf(“Your input number is %dn“,Number); while( !(Number=1 else if( Number = 70 getch(); 用二维数组实现矩阵转置 /* 用二维数组实现矩阵的转置 */

9、 #include #define ROW 3 #define COL 4 main() int matrixAROWCOL,matrixBCOLROW; int i,j; clrscr(); printf(“Enter elements of the matrixA,“); printf(“%d*%d:n“,ROW,COL); for( i=0; imax)/* 保存至 row 行的最小数 */ min=max; printf(“The minimum of maximum number is %dn“,min);for(max=a00,row=0;rowarowcol) min=arowc

10、ol; if(max0) /*ai与 ahigh交换,随之 high 减 1*/ t=ai; ai=ahigh; ahigh=t; high-; else if(ai=0) i+; /* 掠过该元素 */ else /*ai与 alow交换,随之 low 增 1, i 增 1*/ t=ai; ai=alow; alow=t; low+; i+; int s=8,4,0,-1,6,0,-5; main() int i; clrscr(); printf(“n The arry before rest is:n“); for(i=0;i16) s0=0; /* 不合理的进制,置 s 为空字符串 *

11、/ return 0; /* 不合理的进制,函数返回 0 */ bufi=0; do buf-i=digitsn%d; /*译出最低位,对应字符存入对应工作数组中*/ n/=d; while(n); /* 将译出在工作数组中的字符串复制到 s */ for(j=0;(sj=bufi)!=0;j+,i+); /* 其中控制条件可简写成 sj=bufi */ return j; /* 主函数用于测试函数 trans() */main() unsigned int num = 253; int scale=2,3,10,16,1; char str33; int i; clrscr(); for(i

12、=0;i (%d) Error! n“,num,scalei); printf(“n Press any key to quit.n“); getch(); 判断回文数 /* 函数 circle 用于判断正整数 n 的 d 进制数表示形式是否是回文数 */ int circle(int n, int d) int s=0,m=n; while(m) s=s*d+m%d; m/=d; return s=n; /* main 函数用于测试 circle 函数 */ int num=232,27,851; int scale=2,10,16; main() int i,j; clrscr(); for(i=0;i (%d) is a Circle Number!n“,numi,scalej); else printf(“%d - (%d) is not a Circle Number!n“,numi,scalej);printf(“n Press any key to quit.n“); getch(); 求解钢材切割的最佳订单 #include #define N 20 #define DELTA 2 int bestlen; int bestseleN; int s

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号