Chinaunix首页 | 论坛 | 博客
  • 博客访问: 199677
  • 博文数量: 51
  • 博客积分: 1435
  • 博客等级: 上尉
  • 技术积分: 590
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-05 18:33
文章分类

全部博文(51)

文章存档

2012年(17)

2011年(34)

分类: C/C++

2011-06-10 09:03:35

  1. // #include <iostream>

  2. #include "Sales_item.h"
  3. #include <string>
  4. #include <vector>

  5. using std::cin;
  6. using std::cout;
  7. using std::string;
  8. using std::endl;
  9. using std::vector;
  10. int main()
  11. {
  12.     vector<string> text;
  13.     string word;
  14.     cout <<"please input some word" <<endl;
  15.     while(cin>>word)
  16.     {
  17.         for(string::size_type i=0;i!=word.size();++i)
  18.             word[i]=toupper(word[i]);
  19.          text.push_back(word);

  20.     }
  21.     for(vector<string>::size_type i=0;i!=text.size();++i)
  22.     {
  23.         cout<<text[i]<<" ";
  24.         if((i+1)%8==0)
  25.             cout<<endl;
  26.     }
  27.     cout<<endl;
  28.         
  29.     /*vector<int> numbers;
  30.     int a;
  31.     vector<int>::size_type i;
  32.     cout<<"please input a lot of integer"<<endl;
  33.     while(cin>>a)
  34.     {
  35.         numbers.push_back(a);

  36.     }
  37.     
  38.     for(i=0;i<numbers.size()/2;++i)
  39.     {
  40.         cout<<numbers[i]+numbers[numbers.size()-(i+1)]<<endl;
  41.     }
  42.     if(numbers.size()%2!=0)
  43.     {
  44.         cout<<"the mid mumber "<<numbers[i]
  45.         <<" is not taking part in plus"<<endl;
  46.     }
  47.     //另外一种还不错的写法
  48.     for(vector<int>::size_type first=0,last=numbers.size()-1;first<last;++first,--last)
  49.     {
  50.         cout<<numbers[first]+numbers[last]<<endl;
  51.     }
  52.     if(first==last)
  53.     {
  54.         cout<<"the mid number "<<numbers[first]
  55.         <<"is not taking part in plus"<<endl;
  56.     }

  57.     */
  58.     /* for(vector<int>::size_type i=0;i<numbers.size()-1;i=i+2)
  59.     {
  60.         cout<<numbers[i]+numbers[i+1]<<endl;
  61.     }
  62.     if(numbers.size()%2!=0)
  63.         cout<<"the last number "<<numbers[numbers.size()-1]
  64.      <<" is not taking part in plus "<<endl;
  65.      */

  66.     
  67.     /*string word;
  68.     vector<string> text;

  69.     cout<<"please input some word,then these word will push into the text"<<endl;
  70.     cout<<"Enter (CTRL+Z) to end"<<endl;

  71.     while(cin>>word)
  72.     {
  73.         text.push_back(word);
  74.     }
  75.     for(vector<string>::size_type i=0;i<text.size();++i)
  76.         text[i]="";
  77.     cout<<text[0]<<endl;*/
  78.     //string s;
  79.     //cout <<s[0]<<endl;
  80.     /*string s,s1;
  81.     cout <<"please input string should combine punctuation!"<<endl;
  82.     while(getline(cin,s))
  83.     {
  84.         s1="";
  85.         for(string::size_type i=0;i < s.size();++i)
  86.             if(!ispunct(s[i]))
  87.              s1+=s[i];
  88.         cout<<"new string "<<s1<<endl;
  89.         cout <<"please input string should combine punctuation!"<<endl;
  90.     }*/
  91.     /*string str,str1;
  92.     
  93.     cout << "please input some strings!! "<<endl;
  94.     
  95.     while(cin >> str1)
  96.     {
  97.         str+=str1;
  98.         str+=" ";
  99.     }
  100.     cout <<"these strings combine to "<<str<<endl;*/
  101.     /*string str1,str2;
  102.     
  103.     cout << "please input two string ,Then I will show the answer to you !"<<endl;
  104.     
  105.     while(cin>>str1>>str2)
  106.     {
  107.         if(str1==str2)
  108.             cout <<"str1 == str2"<<endl;
  109.         else if(str1 > str2)
  110.             cout << "str1 > str2"<<endl;
  111.         else
  112.             cout <<"str1 < str2"<<endl;
  113.         cout << "please input two string ,Then I will show the answer to you !"<<endl;
  114.     }*/
  115.     /*string line;
  116.     int n;
  117.     string s("Hello World!!!");
  118.     string::size_type punct_cnt=0;
  119.     
  120.     //string str("some string");
  121.     for(string::size_type i=0;i<s.size();++i)
  122.     {
  123.         s[i]=tolower(s[i]);
  124.         if(ispunct(s[i]))
  125.             ++punct_cnt;
  126.     }
  127.     cout << "punctuation characters in " << s <<"is "<< punct_cnt<<endl;
  128.     */
  129.     
  130.  /*
  131.     while(getline(cin,line))
  132.     {
  133.         if(line.empty())
  134.         {
  135.             cout << "line is empty" <<endl;
  136.         }
  137.         n=line.size();
  138.         cout << line.size() << endl;
  139.         cout << n <<endl;
  140.         cout << line << endl;
  141.     }*/

  142.     /*string s1,s2;
  143.     cout << "please input string !" <<endl;
  144.     while(cin >> s1)
  145.     {
  146.         cout << s1 <<endl;
  147.         cout << "please input string" <<endl;
  148.     }*/
  149.     //cin >> s1 >> s2;
  150.     // cout << s1 << s2 << endl;
  151.     /*Sales_item total,item;
  152.     //int count=1;
  153.     //int i=1;
  154.     int i=2.1;
  155.     std::cout<<i<<std::endl;
  156.     const int &r=1;
  157.     const int &r2=r+i;
  158.     unsigned char u=-1;
  159.     cout<<r2<<r<<std::endl;*/
  160.     //std::cout<<i%256<<std::endl;
  161.     /*if(std::cin>>total)
  162.     {
  163.     while(std::cin>>item)
  164.     {
  165.         if(total.same_isbn(item))
  166.         {
  167.             total+=item;
  168.         }
  169.         else
  170.         {
  171.             std::cout<<total<<std::endl;
  172.             total=item;
  173.             
  174.         }
  175.     }
  176.     std::cout<<total<<std::endl;
  177.     }
  178.     else
  179.     {
  180.         std::cout<<"No numbers"<<std::endl;
  181.         return -1;
  182.     }*/
  183.     /*std::cin>>total;
  184.     while(std::cin>>item)
  185.     {
  186.         if(total.same_isbn(item))
  187.             ++count;
  188.         else
  189.         {
  190.             std::cout<<"the countof the previos ISBN is "<<count<<std::endl;
  191.             total=item;
  192.             count=1;
  193.         }    
  194.     }
  195.     std::cout<<"the count of the last ISBN is"<<count<<std::endl;*/


  196.     
  197.     /*std::cin>>item1>>item2;

  198.     if(item1.same_isbn(item2))
  199.     {
  200.         std::cout<<item1+item2<<std::endl;
  201.     }
  202.     else
  203.     {
  204.         std::cout<<"error"<<std::endl;
  205.     }*/
  206.     /*std::cout<< "enter two numbers" <<std::endl;
  207.     int v1,v2;
  208.     std::cin>>v1>>v2;
  209.     std::cout<<"the sum of"<<v1<<"and"<<v2<<"is"<<v1+v2<<std::endl;*/
  210.     return 0;
  211. }
阅读(1540) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~