




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、C#語言上機題目實驗一 C#基礎1. 編一個程序,定義常量Pi=3.14159265,從鍵盤上輸入半徑r,求出圓的面積。2.編一個程序,從鍵盤上輸入三個數(shù),用三元運算符(? :)把最大數(shù)找出來。3.編一個程序,輸入一個字符,如果是大寫字母,就轉換成小寫字母,如果輸入的字符是小寫字母,則轉換為大寫字母,否則不轉換。4.輸入一個字符,判定它是什么類型的字符(大寫字母,小寫字母,數(shù)字或者其它字符)5.編一個程序,定義一個實數(shù)變量,從鍵盤上輸入一個值,如果這個值在閉區(qū)間0,100里,則加上1000,否則不加。最后輸出結果。6.編一個程序,輸入一個正數(shù),對該數(shù)進行四舍五入到個位數(shù)的運算。例如,實數(shù)12.
2、56經(jīng)過四舍五入運算,得到結果13;而12.46經(jīng)過四舍五入運算,得到結果12。7.編寫一個程序,定義三個float類型的變量,分別從鍵盤上輸入值給它們, 然后用if else選擇語句找出它們中的最小數(shù),最后輸出結果。8. 編一個程序,首先輸入一個成績(0到100的整數(shù)),分別用if else語句和Switch語句判斷該成績是優(yōu)、良、中、及格還是不及格,如果是100分還需輸出時滿分。9.編一個程序,利用do-while循環(huán)語句,從鍵盤上輸入10個整數(shù),求出它們的和。10. 編一個程序,用while循環(huán)語句來計算1+1/2+2/3+3/4+.+99/100之和。11.編一個程序,打印出所有的“水
3、仙花數(shù)”,所謂“水仙花數(shù)”是指一個三位數(shù),其各位數(shù)字立方和等于該數(shù)本身。例如, 153=1*1*1+5*5*5+3*3*3,所以153是“水仙花數(shù)”12. 有關系式1*1+2*2+3*3+.+k*k b ? a : b; k = k c ? k : c; Console.WriteLine(0,1,2最大的為3,a,b,c,k); public static void T3() char x = Convert.ToChar(Console.Read(); int a = A; int b = a; if (x = a & x =A&x= 0 & x = a & x = A & x = 0 &
4、 a b) a = b; if (a c) a = c; Console.WriteLine(0,a); public static void T8() double a = Convert.ToDouble(Console.ReadLine(); if (a = 100) Console.WriteLine(100fen); else if (a = 90) Console.WriteLine(youxiu); else if (a = 80) Console.WriteLine(lianghao); else if (a = 70) Console.WriteLine(zhongdeng)
5、; else if (a = 60) Console.WriteLine(jige); else Console.WriteLine(bujige); public static void T9() int sum = 0; int i = 1; do int a = Convert.ToInt32(Console.ReadLine(); sum += a; i+; while (i 0) sum += (i-1)0?i-1:1) / i; i-; Console.WriteLine(0,sum); public static void T11() for (int i = 100; i 10
6、00; +i) int a = i % 10; int b = i / 100; int c = (i / 10) % 10; if (a * a*a + b * b*b + c*c * c = i) Console.WriteLine(0,i); public static void T12() for (int i = 1; i = 2000; +i) int sum = 0; for (int j = 1; j = 2000) Console.WriteLine(0,i-1); return; public static void T13() for (int i = 1; i = 9;
7、 +i) for (int j = 1; j = i; +j) Console.Write(0*1=2 ,i,j,i*j); Console.WriteLine(); public static void T14() int x, y, z; for (x = 0; x = 100; +x) for (y = 0; y = 100; +y) for (z = 0; z = 100; +z) if (x + y + z = 100 ) if(z%3=0 & 5 * x + 3 * y + z / 3 = 100)Console.WriteLine(x=0,y=1,z=2,x,y,z); publ
8、ic static void T15() int a = new int100; int p = 0; for(int i = 0;i 10; +i) int x = Convert.ToInt32(Console.ReadLine(); int judge = p; for(int j = 0;j x) judge = j; break; p+; for(int j = p-1;j judge; -j) aj = aj-1; ajudge = x; for(int j = 0;j =a&c=A&c=Z)b+; Console.WriteLine(小寫:0個,大寫:1個,a,b); publi
9、c static void T17() String str1 = Console.ReadLine(); char str2 = new char100; int i = 0; foreach (char x in str1) str2i+ = x; str2i = 0; for(int j = 0;j i; +j) Console.Write(0,str2j); Console.WriteLine(); public static void T18() int vis = new int30; string str = Console.ReadLine(); for (int i = 0;
10、 i str.Length; +i) int x = 0; if (visstri - a = 0) for (int j = i + 1; j 0) Console.WriteLine(0重復出現(xiàn)1次, stri, x); visstri - a+; public static void MaxminArray(int num,ref int x,ref int y) x = num0; y = num0; foreach (int a in num) if (x a) y = a; public static void T19() int x = 0; int y = 0; int num
11、=-1,1,2,3,5; MaxminArray(num,ref x,ref y); Console.WriteLine(max=0,min=1,x,y); public static void SortArray(int num, bool flag) for (int i = 0; i num.Length; +i) for (int j = i + 1; j numj) = flag) int t = numi; numi = numj; numj = t; public static void T20() int num = -1, 1, 2, 3, 5 ,10, -2, 15; SortArray(num, false); foreach (
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030中國二手車交易行業(yè)發(fā)展分析及發(fā)展前景與趨勢預測研究報告
- 樓內(nèi)線改造方案
- 糧庫曬臺施工方案
- 2025-2030中國2-氨基-5-溴三氟甲苯行業(yè)前景動態(tài)與需求狀況分析報告
- 餐廳應急物資儲備方案
- 農(nóng)村果園管道改造方案
- 監(jiān)管項目資金使用方案
- 公園正規(guī)安全服務方案
- 無錫工廠拆除方案
- 地鐵設計組織方案
- JG/T 302-2011卷簾門窗
- 帶狀皰疹課件(課件演示)
- T/CAS 413-2020排水管道檢測和非開挖修復工程監(jiān)理規(guī)程
- 小酒館合伙人合作協(xié)議書
- 電玩城入股合同范本
- 2025-2030中國搜索引擎行業(yè)現(xiàn)狀供需分析及市場深度研究發(fā)展前景及規(guī)劃可行性分析研究報告
- 驛站合伙承包協(xié)議書
- 2025年社會工作專業(yè)資格考試試題及答案
- 拖欠房租分期協(xié)議書
- 藍莓鮮果采購合同協(xié)議
- 人事行政部2025年部門工作總結模版
評論
0/150
提交評論