`
ccjsjymg
  • 浏览: 60747 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表
引用 在c++中,使用c++ rand()获取随机数必须结合srand(time(NULL)),rand()是依靠初始化值产生随机数,而srand(time(NULL))初始化初始值,使每次产生的随机数不一样。在不使用srand(time(NULL)),通过测试遍历一万遍对于某个数出现的频率很大,如:() int flag1 = 0; for(int i = 0;i <= 100000000;i++) { //srand(time(NULL)); int a = rand()%101; if ...
#include <iostream> #include <time.h> using namespace std; int main() {     struct tm pp,*p = NULL;//如果这里不初始化,此时p不是NULL     if(p == NULL)     {        cout<<"hello"<<endl;      }      system("PAUSE"); }
首先一个正整数t,表示测试用例的数量。 对每组数据,首先输入一个n(1<=n<=10000),表示参赛队伍的数量。然后有n行,每行为: Team-name Problems Penalty Info 其中Team-name表示队名(长度不超过20),Problems表示解题数量(32位有符号整数可以表示),Penalty表示罚时(32位有符号整数可以表示),Info为M表示女队,N表示正常队伍。 排序后的结果,格式与输入相同。 首先根据题目数量由多至少,同等题目情况下女队优先,然后罚时少者优先,最后按队名字典序。 每组样例后输出一个空行。
引用 一个参赛队伍不能超过三人,可以拥有一个替补。包括替补在内任何参赛队员必须为高中毕业五年内,才可以参赛, 也就是说研究生一年级的学生还可以参加。 现在的问题是给你一个队伍,请判断这个队伍是否合法。 输入数据: 输入数据包括若干组,每一组包括有若干行,第一行为一个整数N,为这个队伍的人数,接着有N行,每 一行包括一个字符串(字符串中间没有空格)和一个整数, 字符串表示队员姓名,整数表示这个队员高中毕业的年份(2009表示已经毕业)。 输出数据: 请判断输入的那组数据是否能够成一个合法的赛队,如果合法则输出yes,否则输出no。(现在的年份是2009年)
引用 题目如下: 公司选举领导,有三名候选人,有50名员工参加投票(不包括3名候选人,但可以参加选举), 选出获胜者,并输出三名候选人票数。 希望大家积极交流,共同进步。。。。。。。。。
int main(){ char arra[] = "abcd"; char *ch =arra; while((*ch++ = *arra++) != '\0' ) { cout<<*ch; } } 为什么不能non-reference类型作为左值,这里不太理解,哪位大侠能解释下。。。。。。。。
#include <iostream> #include <string> #include <math.h> #include <vector> using namespace std; /* * 把数字转化为ascii码 */ int getChar_Asci(int a){ switch (a) { case 1: a = 49; break; case 2: a = 50; break; case 3: a = 51; break; ...
/* * 把数字转化为ascii码 */ int getChar_Ascii(int a){ switch (a) { case 1: a +=48; break; case 2: a +=48; break; case 3: a +=48; break; case 4: a +=48; break; case 5: a +=48; break; case 6: a +=48; break; case 7: a +=48; ...
#include <iostream> #include <vector> #include <string> #include <sstream> #include <math.h> #define le 10 using namespace std; string getString(const int a); unsigned stringToInt(string str); unsigned ts(string str,unsigned maxI); unsigned getInt(); int get ...
大哥们,我想把一个任意整数拆分,用到pow两次函数,结果产生误差,不太理解,有哪位帮忙解决一下? #include <iostream> #include <vector> #include <string> #include <sstream> #include <math.h> #define length 10 using namespace std; string getString(const int a); unsigned long getInt(); int getLen(int b); /* ...
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot open output file testc++.exe: Permission denied collect2: ld returned 1 exit status make: *** [testc++.exe] Error 1 make: Target `all' not remade because of errors. Build complete for project testc++ 我用dev-c++编译后,再到eclipse编 ...
string intToString(const int a){ int b = a; int *c = &b; char *t; t = (char*)c; cout<<t<<endl; std::string s; s = t; return s; } 问问大哥们t是乱码?
#include <string.h> void testPoint(){ char cc[] = "hello"; char *c = cc; strcpy(c,"dd"); //如果char *c = "hello";再用strcpy(c,"dd")会出现程序崩溃?不太理解,有谁帮解一下? }
#include <iostream.h> void print_01(){ int rowS = 10; for(int i = 0;i < rowS;i++){ if(i % 2 != 0){ int j = (rowS-1 - i)/2; for(int j1 = 0;j1 < j;j1++){ cout<<" "; } for(int k = 0;k < i;k++){ cout<<"*"; } for(in ...
#include <iostream.h> /** * 输入年份和月来统计当月有多少天 */ bool isleapYear(int year){ if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) return true; else return false; } int getDays(int year,int month){ int day = 0; if(month < 8){ for(int i = 1;i <= 7;i++) ...
Global site tag (gtag.js) - Google Analytics