pyman hall

转向python,学无止境!

记得有个程序题,是写出个类似《黑客帝国》里面数据流的程序,这两天复习复习C语言,觉得还挺好玩的(只为好玩)

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#define N 150

int main (void) {
   int x, max = 0, n = 20000, i = 0, j = 0, k = 0, area[N] = {0};
   char print_format[N], print_shape[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

   srand((int)time(0));
   for (i = 0; i < n; i++) {
       x = rand() % N;
       area[x]++;
   }

   for (i = 0; i < N; i++){
       if (max < area[i])
           max = area[i];
   }

   for (i = 1; i <= max; i++) {
       for ( k = 0; k < 20000000; k++);

       for ( j = 0; j < N; j++) {
           if ( i > area[j] )
               printf(" ");
           else {
               x = rand() % 10;
               printf("%c", print_shape[x]);
           }
       }
       printf("\n");
   }
   return 0;
}



阅读更多
文章标签: 语言 c include
个人分类: C
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭