C++测试代码

#include <ctime>

#include <cstdlib>

#include <string>

#include <iostream>

using namespace std;

int main() {  

   string charSet;

   int times = 100;

   int magic, i;  

  char randomChar;

   srand(time(NULL));

   for (i = 1; i<= times; i++)  

    {   magic = rand()%26;  

       randomChar = 'a'+magic;

      charSet += randomChar;

     }

   cout << "random char set:\n"<<charSet<<endl;  return 0;

}

 

 

 

// #include<iostream>
// using namespace std;
// void swap(int *p1,int*p2)
// {
//  int temp;
//  temp = *p1;
//  *p1 = *p2;
//  *p2 = temp;
//
// }
// int main()
// {
//  int x1 = 3,x2 = 5;
//  cout << "before swap,x1 = "<<x1<<",x2 = "<<x2<<endl;
//  swap(&x1,&x2);
//  cout << "after swap,x1 = "<<x1<<",x2 = "<<x2<<endl;
// }

posted @ 2013-10-27 20:04  Star阿七  阅读(966)  评论(0编辑  收藏  举报