Linux C一站式学习 第八章第三小节习题一答案
生活随笔
收集整理的這篇文章主要介紹了
Linux C一站式学习 第八章第三小节习题一答案
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
為什么80%的碼農都做不了架構師?>>> ??
#include<stdio.h>
#define N 100
int array[N];
void get_random(int upper)
{
?int i;
?for(i=0; i<N; i++)
??? array[i] = rand() % upper;
}
int howmany(int value)
{
?int i, count;
?count = 0;
?for(i=0; i<N; i++)
??? if(array[i] == value)
??? ??? count++;
?return count;
}
void print_pic(int level_count, int *each_count)
{
?int i;
?printf(" ");
?if(level_count == 0)
?? {
???? for(i=0; i<10; i++)
??? ??? printf("%d ", i);
??? printf("\n");
?? }
?else
?? {
??? for(i=0; i<10; i++)
??? ?{
??? ??? if(*(each_count+i) > 0)
??? ??? {
??? ??? ??? printf("* ");
??? ??? ??? each_count[i]--;//*(each_count+i) is constant, so it can't be lvalue. each_count[i] is variable.
??? ??? }
??? ??? else
??? ??? ??? printf("? ");
??? ?}
??? printf("\n");
?? }
}
int main()
{
?int i, count[10], max;
?get_random(10);
?for(i=0; i<10; i++)
??? count[i] = howmany(i);
?max = count[0];
?for(i=1; i<10; i++)
???? if(max < count[i])
???? ??? max = count[i];
?for(i=0; i<max; i++)
??? print_pic(i, count);
}
轉載于:https://my.oschina.net/gater/blog/11990
總結
以上是生活随笔為你收集整理的Linux C一站式学习 第八章第三小节习题一答案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java面试和笔试大全
- 下一篇: 社区奖品之原木双面记事板