rand()
编写一个程序,根据键盘输入的数字n,生成n个伪随机函数,统计并输出其中能被2整除的数的个数。 要求使用rand()
-------------------------------------------------------- #include #include #include int main() { int Tmp; int Count = 0; int N = 0; srand((unsigned int)time(0)); printf("N : "); scanf(" %d", &N); while((N--)>1) { Tmp = rand(); if(Tmp%2 == 0) { printf("%d ", Tmp); ++Count; } } printf("\r\nTotal : %d", Count); system("pause"); return 0; }。
答:晕 ··· 怎么一回答就发到评论里了·· 答案是1236543210详情>>
问:挺简单的一C函数,不过我是初学者,暂时还不会写,请好心人多多帮忙!
答:int mystrlen(char *str) { int n = 0; while (*str) { n++; str++;} return n; } voi...详情>>