我不知道该怎么办请帮助 [英] I dont know what to do please help

查看:97
本文介绍了我不知道该怎么办请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个程序,创建一个包含1000个条目的整数数组。

创建数组后,将数组中的所有值初始化为0.接下来,使用rand函数,循环遍历数组并在每个条目中保存1到10之间的随机数。

数组。



我尝试过:



我知道该做什么或如何开始它请帮助

Write a program that will create an integer array with 1000 entries.
After creating the array, initialize all of the values in the array to 0. Next, using the rand function, loop through the array and save a random number between 1 and 10 in each entry of
the array.

What I have tried:

I have know idea on what to do or how to start it please help

推荐答案

引用:

我知道该做什么或如何开始请帮助

I have know idea on what to do or how to start it please help



没有!你试着让我们相信你从来没有一门关于C编程的课程,而且老师只是扔了一个与你迄今为止所做的任何课程无关的随机作业。


NO! You try to make us believe that you never had a single course about C programming and that the teacher just trowed a random homework unrelated to any course you have done so far.

引用:

如何开始



你开始编写这个C程序,就像你见过或写过的任何C程序一样。 />


此要求是您将看到的最简单的一项要求。仔细阅读并开始工作,这真的不复杂。



我们不做你的家庭作业。

HomeWork不会测试你的乞求其他人做你的工作的技巧,它会让你思考并帮助你的老师检查你对所学课程的理解,以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果你遇到一个特定的问题,显示你的代码并解释这个确切的问题,我们可能会帮忙。


You start to write this C program exactly like any C program you ever seen or written.

This requirement is 1 of the most simple you will ever see. read carefully and start to work, it really not complicated.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.


每次都会生成1000个随机数,但唯一的一点是平均值总是5(没有多次运行所以平均可能有5次以上)在linux ubuntu 16.04上完成
,codeblocks,也不需要将数组中的每个值初始化为0.希望这有帮助

this generates 1000 random numbers everytime, but the only thing is that the average is always 5(did not run as many times so there might be an average other than 5)
done on linux ubuntu 16.04, codeblocks, also no need to initialize every value in the array to 0. Hope this helped
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main(){
    srand(time(NULL));
    int a[1000], sum=0,num[10];
    float avg;
    for(int i=0; i<1000; i++){
        a[i]=rand()%10+1;
    }
    for(int j=0; j<999; j++){
        sum+=a[j];
    }
    avg=sum/1000;
    for(int m=0; m<10; m++){
        num[m]=0;
    }
    for(int k=0 ;k<999; k++){
        for(int n=0; n<10; n++){
            if(a[k]==n+1){
                num[n]++;
            }
        }
    }
    cout<<"Sum "<<sum<<endl<<"average "<<avg<<endl;
    for(int x=0; x<10; x++){
        cout<<"number "<<x+1<<" was generated "<<num[x]<<" times\n";
    }
}


这篇关于我不知道该怎么办请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆