浙江大學PAT上機題解析之1006. 換個格式輸出整數 (15)

來源:互聯網
上載者:User
1006. 換個格式輸出整數 (15)時間限制  400 ms
記憶體限制  32000 kB
代碼長度限制  8000 B
判題程式    Standard作者    CHEN, Yue

讓我們用字母B來表示“百”、字母S表示“十”,用“12...n”來表示個位元字n(<10),換個格式來輸出任一個不超過3位的正整數。例如234應該被輸出為BBSSS1234,因為它有2個“百”、3個“十”、以及個位的4。

輸入格式:每個測試輸入包含1個測試案例,給出正整數n(<1000)。

輸出格式:每個測試案例的輸出佔一行,用規定的格式輸出n。

輸入範例1:

234

輸出範例1:

BBSSS1234

輸入範例2:

23

輸出範例2:

SS123
 
#include<iostream>using namespace std;int main(){  int N,i;  int  b=0;  int  s=0;  int  g=0;  cin>>N;  g = N%10;     N/=10;    s = N%10;  N/=10;  b = N%10;  for (i=0;i<b;i++)  cout<<"B";  for (i=0;i<s;i++)  cout<<"S";  for (i=1;i<=g;i++)    cout<<i;  cout<<endl;  return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.