網頁

2017年3月21日 星期二

Ex4 C++輸入輸出練習

輸入某一長度字串,如
"how are u"

輸出為:
how are u
 ow are u
  w are u
    are u
    are u
     re u
      e u
        u
        u

28 則留言:

  1. B10333070 徐承瑋2017年3月21日 上午11:17

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a String:" ;
    getline(cin, x);
    int n=1;
    cout<<setw(n)<<x<<endl;
    int len=x.length();

    for (int i=1;i<len;i++)
    {
    string y="";
    for (int j=i;j<len;j++)
    y+=x[j];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  2. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int n=10;
    cout<<setw(n)<<x<<endl;
    int len=x.length();
    for(int j=0;j<len;j++)
    {
    string y="";
    for(int i=j;i<len;i++)
    y+=x[i];
    cout<<setw(n)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  3. B10333106 劉郁芃2017年3月21日 上午11:22

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0;
    }

    回覆刪除
  4. B10333063 羅胤銓2017年3月21日 上午11:23

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Enter:";
    getline(cin, x);
    int len=x.length();
    for(int i=0; i<len; i++)
    {
    string y="";
    for(int j=i;j<len; j++)
    y+=x[j];
    cout<<setw(len)<<y<<endl;
    }

    system("Pause");
    return 0;
    }

    回覆刪除
  5. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int n=x.length();
    int len=x.length();
    for(int i=0;i<len;i++){
    string y="";
    for(int j=i;j<len;j++){
    y+=x[j];
    }
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0;
    }

    回覆刪除
  6. B10333086 陳晏堂2017年3月21日 上午11:24

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test......");
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int j=0;j<len; j++)
    {
    string y="";
    for(int i=j;i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0;
    }

    回覆刪除
  7. B10333027 毛冠霖2017年3月21日 上午11:25

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a string";
    getline(cin, x);
    int n=x.length();
    int len=x.length();

    for(int i=0;i<len;i++){
    string y="";
    for(int j=i;j<len; j++){
    y+=x[j];
    }
    cout<<setw(len)<<y<<endl;
    }


    system("Pause");
    return 0;
    }

    回覆刪除
  8. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test...... ");
    cout<<"Input a string:";
    getline(cin, x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;

    }

    回覆刪除
  9. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {

    string x;
    sytem("echo test test......");
    cout<<"Input a string:";
    getling(cin, x);
    int len=x.length();
    for (int j=0; j<len; j++)
    {
    string y="";
    for(int i=2; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0;

    }

    回覆刪除
  10. #include<iostream>
    #include<cstdlib>
    #include<string>
    #include<iomanip>
    using namespace std;
    int main()
    {

    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int j=0;j<len;j++)
    {
    string y="";
    for(int i=j;i<len;i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  11. B10333107-曾詠浩2017年3月21日 上午11:27

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int i=0 ; i<len; i++)
    {
    string y="";
    for(int j=i ;j<len;j++)
    y+=x[j];
    cout<<y<<setw(len)<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  12. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;

    cout<<"Input a string:";
    getline(cin, x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  13. #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test.....");
    cout<<"Input a string:";
    getline(cin, x);
    int len=x.length();
    for (int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  14. #include
    #include
    #include
    #include
    using namespace std;
    int main() {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int n=9;
    int len=x.length();

    for(int j=0;j

    回覆刪除
  15. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test..... ");
    cout<<"Input a string:";
    getline(cin, x);
    int len=x.length();

    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  16. #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int i=0 ; i<len; i++)
    {
    string y="";
    for(int j=i ;j<len;j++)
    y+=x[j];
    cout<<y<<setw(len)<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  17. B10333072 黃玟茜2017年3月21日 上午11:30

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test......");
    cout << "Input a string:";
    getline(cin,x);
    int len=x.length();
    for (int j=0; j<len; j++)
    {
    string y="";
    for (int i=j; i<len; i++)
    y+=x[i];
    cout << setw(len) << y << endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  18. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main() {
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int n=9;
    int len=x.length();

    for(int j=0;j<len;j++){

    string y="";
    for(int i=j;i<len;i++)
    y+=x[i];
    cout<<setw(n)<<y<<endl;
    }

    system("Pause");
    return 0;
    }

    回覆刪除
  19. B10333077 潘家銘2017年3月21日 上午11:38

    #include<iostream>
    #include<cstdlib>
    #include<string>
    #include<iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test.....");
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for (int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0 ;

    }

    回覆刪除
  20. B10333053 梁竣翔2017年3月21日 上午11:38

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test..... ");
    cout<<"Input a string:";
    getline(cin, x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0 ;
    }

    回覆刪除
  21. B10333079 葉禮魁2017年3月21日 上午11:39

    #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>

    using namespace std;

    int main(){
    string x;
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int z=0 ; z<len ; z++){
    string y="";
    for(int i=z ; i<=len ; i++)

    y+=x[i];
    cout<<setw(len)<<y<<endl;

    }
    system("Pause");
    return 0;
    }

    回覆刪除
  22. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test..... ");
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  23. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test..... ");
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  24. #include <iostream>
    #include <cstdlib>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test..... ");
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for(int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("Pause");
    return 0;
    }

    回覆刪除
  25. B10333077 潘家銘2017年3月21日 上午11:45

    #include<iostream>
    #include<cstdlib>
    #include<string>
    #include<iomanip>
    using namespace std;
    int main()
    {
    string x;
    system("echo test test.....");
    cout<<"Input a string:";
    getline(cin,x);
    int len=x.length();
    for (int j=0; j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }
    system("pause");
    return 0 ;

    }

    回覆刪除
  26. b10133187 楊鈞文2017年3月21日 上午11:45

    #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    string x;
    system("echo test test.....");
    cout<<"Input a string";
    getline(cin,x);
    int len=x.length();
    for(int j=0;j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }


    system("pause");
    return 0;
    }

    回覆刪除
  27. b10133187 楊鈞文2017年3月21日 上午11:46

    #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    string x;
    system("echo test test.....");
    cout<<"Input a string";
    getline(cin,x);
    int len=x.length();
    for(int j=0;j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }


    system("pause");
    return 0;
    }

    回覆刪除
  28. B10333053 梁竣翔2017年6月20日 上午10:35

    #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    string x;
    system("echo test test.....");
    cout<<"Input a string";
    getline(cin,x);
    int len=x.length();
    for(int j=0;j<len; j++)
    {
    string y="";
    for(int i=j; i<len; i++)
    y+=x[i];
    cout<<setw(len)<<y<<endl;
    }


    system("pause");
    return 0;
    }

    回覆刪除

HTML 編輯器