1. 程式人生 > >c語言實踐:RS信號報告

c語言實踐:RS信號報告

pro -- pri pad quit 字母 逗號 alt scanf

題目:

無線電臺的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.

int main()
{
   
	//保存輸入的SR值
	int SR = 0;
	
	//保存分類出來的S和R
	int S = 0;
	int R = 0;

	//校驗輸入的合法性
	scanf_s("%d", &SR);

	S = SR / 10;
	R = SR % 10;
	if (S < 1 || S>9 || R < 1 || R>5)
	{
		printf("wrong input ,program will quit at once");
		return 0;
	}

	switch (S)
	{
		case 1:printf("Faint signals, barely perceptible,"); break;
		case 2:printf("Very weak signals,"); break;
		case 3:printf("Weak signals,"); break;
		case 4:printf("Fair signals,"); break;
		case 5:printf("Fairly good signals,"); break;
		case 6:printf("Good signals,"); break;
		case 7:printf("Moderately strong signals,"); break;
		case 8:printf("Strong signals,"); break;
		case 9:printf("Extremely strong signals,"); break;
	}

	switch (R)
	{
	case 1:printf("Unreadable"); break;
	case 2:printf("Barely readable, occasional words distinguishable"); break;
	case 3:printf("Readable with considerable difficulty"); break;
	case 4:printf("Readable with practically no difficulty"); break;
	case 5:printf("Perfectly readable"); break;
	}

	return 1;

}

  

c語言實踐:RS信號報告