返回列表 發帖

字串處理 (九) - 將ASCII碼轉換為字串

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int start, end;
  7.     cout<<"在此輸入ASCII碼範圍(0~127)"<<endl;
  8.     cout<<"起始值: ";
  9.     cin>>start;
  10.     cout<<"終止值: ";
  11.     cin>>end;
  12.     cout<<"所得字串:"<<endl;
  13.     for(int i=start; i<=end; i++)
  14.         cout<<char(i);
  15.     cout<<endl;
  16.     system("pause");
  17.     return 0;   
  18. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     int start, end;
  8.    cout<<"在此輸入ASCII碼範圍(0~127)"<<endl;
  9.      cout<<"起始點: ";
  10.     cin>>start;
  11.     cout<<"終止點: ";
  12.     cin>>end;
  13.     cout<<"所的字串"<<endl;
  14.     for(int i=start; i<=end; i++)
  15.         cout<<char(i);
  16.     cout<<endl;
  17.     system("pause");     
  18.     return 0;   
  19. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>

  3. using namespace std;
  4. int main()
  5. {
  6.    int start,end;
  7.    cout<<"請輸入ASCII範圍(1-127)"<<endl;
  8.    cout<<"起始值"<<endl;
  9.    cin>>start;
  10.    cout<<"終止值"<<endl;
  11.    cin>>end;
  12.    
  13.    cout<<"所得字串"<<endl;
  14.    for(int i=start;i<=end;i++)
  15.    cout<<char(i);
  16.    cout<<endl;
  17.    
  18.    system("pause");
  19.    return 0;
  20. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int start,end;
  7.     cout<<"在此輸入ASCII碼範圍(0~127)"<<endl;
  8.     cout<<"起始值:";
  9.     cin>>start;
  10.     cout<<"終止值:";
  11.     cin>>end;
  12.     cout<<"所得字串:"<<endl;
  13.     for(int i=start;i<=end;i++)
  14.         cout<<char(i);
  15.     cout<<endl;   
  16.     system("pause");
  17.     return 0;      
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int start, end;
  7.    cout<<"在此輸入ASCII碼範圍(0~127)"<<endl;
  8.    cout<<"起始值: ";
  9.    cin>>start;      
  10.    cout<<"終止值: ";
  11.    cin>>end;
  12.    cout<<"所得字串為: "<<endl;
  13.    for(int i=start; i<end; i++)
  14.    cout<<char(i);
  15.    cout<<endl;
  16.    
  17.    system("pause");
  18.    return 0;
  19. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int s, e;
  7.     cout<<"輸入ASCII碼範圍(0~127)"<<endl;
  8.     cout<<"起始值: ";
  9.     cin>>s;
  10.     cout<<"終止值: ";
  11.     cin>>e;
  12.     cout<<"所得字串:"<<endl;
  13.     for(int i=s; i<=e; i++)
  14.         cout<<char(i);
  15.     cout<<endl;
  16.     system("pause");
  17.     return 0;   
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int start, end;
  7.     cout<<"在此輸入ASCII碼範圍(0~127)"<<endl;
  8.     cout<<"起始: ";
  9.     cin>>start;
  10.     cout<<"終止: ";
  11.     cin>>end;
  12.     cout<<"所得字串:"<<endl;
  13.     for(int i=start; i<=end; i++)
  14.         cout<<char(i);
  15.     cout<<endl;
  16.     system("pause");
  17.     return 0;   
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int start ,end;
  7.     cout<<"起點:";
  8.     cin>>start;
  9.     cout<<"終點:";
  10.     cin>>end;
  11.     for(int i=start; i<=end; i++)
  12.     cout<<i<<"->"<<char(i)<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

返回列表