|
发表于 2014-5-20 21:38:58
|
显示全部楼层
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- int array[100];
- int i;
- int count = 0;
- for (i = 0; i < 100; i++)
- {
- array[i] = 100 * rand() / RAND_MAX;
- }
- for (i = 0; i < 100; i++)
- {
- if (array[i] % 3 == 0 && array[i] % 5 == 0)
- {
- printf("%d, ~\t", array[i]);
- count++;
- }
- else if (0 == array[i] % 3)
- {
- printf("%d, *\t", array[i]);
- count++;
- }
- else if (0 == array[i] % 5)
- {
- printf("%d, #\t", array[i]);
- count++;
- }
- if (count && count % 5 == 0)
- {
- printf("\n");
- count = 0;
- }
- }
- printf("\n");
- return 0;
- }
复制代码 这是我自己写的代码,和大家分享一下,和楼主的方法是一样的,加了个可以每5个换行的功能,希望大家不要喷! |
|