編程習題 C

來源:互聯網
上載者:User

標籤:

1.

逆序的三位元(5分)

題目內容:

程式每次讀入一個正三位元,然後輸出逆序的數字。注意,當輸入的數字含有結尾的0時,輸出不應帶有前置的0。比如輸入700,輸出應該是7。

輸入格式:

每個測試是一個3位的正整數。

輸出格式:

輸出逆序的數。

輸入範例:

123

輸出範例:

321

時間限制:500ms記憶體限制:32000kb  2.時間換算(5分)

題目內容:

UTC是世界協調時,BJT是北京時間,UTC時間相當於BJT減去8。現在,你的程式要讀入一個整數,表示BJT的時和分。整數的個位和十位表示分,百位和千位表示小時。如果小時小於10,則沒有千位部分;如果小時是0,則沒有百位部分;如果分小於10分,需要保留十位上的0。如1124表示11點24分,而905表示9點5分,36表示0點36分,7表示0點7分。

有效輸入範圍是0到2359,即你的程式不可能從測試伺服器讀到0到2359以外的輸入資料。

你的程式要輸出這個時間對應的UTC時間,輸出的格式和輸入的相同,即輸出一個整數,表示UTC的時和分。整數的個位和十位表示分,百位和千位表示小時。如果小時小於10,則沒有千位部分;如果小時是0,則沒有百位部分;如果分小於10分,需要保留十位上的0。

提醒:要小心跨日的換算。

輸入格式:

一個整數,表示BJT的時和分。整數的個位和十位表示分,百位和千位表示小時。如果小時小於10,則沒有千位部分;如果小時是0,則沒有百位部分;如果分小於10分,需要保留十位上的0。

輸出格式:

一個整數,表示UTC的時和分。整數的個位和十位表示分,百位和千位表示小時。如果小時小於10,則沒有千位部分;如果小時是0,則沒有百位部分;如果分小於10分,需要保留十位上的0。

輸入範例:

903

輸出範例:

103

時間限制:500ms記憶體限制:32000kb選擇語言你可以在此直接線上輸入程式碼。 3.訊號報告(5分)

題目內容:

無線電台的RS制訊號報告是由三兩個部分組成的:

R(Readability) 訊號可辨度即清晰度.

S(Strength)    訊號強度即大小.

其中R位於報告第一位,共分5級,用1—5數字表示.

  • 1---Unreadable

  • 2---Barely readable, occasional words distinguishable

  • 3---Readable with considerable difficulty

  • 4---Readable with practically no difficulty

  • 5---Perfectly readable

報告第二位是S,共分九個層級,用1—9中的一位元字表示

  • 1---Faint signals, barely perceptible

  • 2---Very weak signals

  • 3---Weak signals

  • 4---Fair signals

  • 5---Fairly good signals

  • 6---Good signals

  • 7---Moderately strong signals

  • 8---Strong signals

  • 9---Extremely strong signals

現在,你的程式要讀入一個訊號報告的數字,然後輸出對應的含義。如讀到59,則輸出:

  1. Extremely strong signals, perfectly readable.

輸入格式:

一個整數,訊號報告。整數的十位部分表示可辨度,個位部分表示強度。輸入的整數範圍是[11,59],這個範圍外的數字不可能出現在測試資料中。

輸出格式:

一句話,表示這個訊號報告的意義。按照題目中的文字,先輸出表示強度的文字,跟上逗號和空格,然後是表示可辨度的文字,跟上句號。注意可辨度的句子的第一個字母是小寫。注意這裡的標點符號都是英文的。

輸入範例:

33

輸出範例:

  1. Weak signals, readable with considerable difficulty.
時間限制:500ms記憶體限制:32000kb *************************************************************************1.計算時間差:
 1 #include <stdio.h>  2 int main() 3 { 4     int hour = 0; 5     int min = 0; 6     int hr1,hr2,min1,min2; 7     printf("please input time1 and time2\n"); 8     scanf("%d %d",&hr1,&min1); 9     scanf("%d %d",&hr2,&min2);10     hour = hr2-hr1;11     min = min2-min1;12     13     if(min<0){14     min = min+60;15     hour = hour-1;16     }17     18     printf("This is %d hours and %d mins",hour,min);19     return 0;20 }
View Code

 2.設計一個找零計數器

 1 #include<stdio.h>  2 int main() 3 {    4     int pay,dollor; 5     printf("please input the pay and dollor\n"); 6     scanf("%d %d",&pay,&dollor); 7     int checkpay = pay - dollor; 8      9     if(checkpay<0){10         printf("please put more money!\n");11     }12     else{13         printf("this is the more %d  money and present!",checkpay);14     }15     16     return 0;17 }
View Code

 3.實現a b互換

 1 #include <stdio.h> 2 int main() 3 { 4     int a,b; 5     scanf("%d %d",&a,&b); 6     int t = a; 7     a = b; 8     b = t; 9     printf("a = %d b = %d\n",a,b);10      11     return 0;12 }
View Code

4.求abc中的最大值

 1 #include <stdio.h> 2 int main() 3 { 4     int a,b,c,max; 5     scanf("%d %d %d",&a,&b,&c); 6      7     if(a>b){ 8         if(a>c){ 9             max = a;10         }11         else{12             max = b;13         }14     }15     else{16         if(b>c){17             max = b;18         }19         else20         {21             max = c;22         }23     }24     printf("the max is %d\n",max);25     26     return 0;27 }
View Code

 5.5分制

 1 #include <stdio.h>  2 int main() 3 { 4     int score,grade; 5     scanf("%d",&score); 6     switch(score/10){ 7         case 10: 8         case  9: printf("the score is A\n"); 9         break;10         case 8:printf("the score is B");11         break;12         case 7:printf("the score is C");13         break;14         case 6:printf("the score is D");15         break;16         default:printf("the score is E");17     }18     19     return 0;20 }
View Code

 

    

編程習題 C

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.