我该如何解决这个问题?帮我 [英] How can I solve this question? Help me

查看:53
本文介绍了我该如何解决这个问题?帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。正如你所看到的那样,我不是英语母语人士,也不是在美国学习。(我知道这很明显)



我的老师给了我这个作业用英语写的,我研究了c语言只用了一个月。



仍然一切都让我感到困惑。



这是我第一次访问该网站,所以如果我的问题有点问题,请原谅我。



这就是问题。









[2]编写一个程序,要求用户输入1到16之间的数字(按任意顺序),然​​后以4乘4排列显示数字,然后显示行,列和对角线的总和。 />


[示例输入/输出]下划线部分由用户输入



输入从1到1的数字16以任何顺序:

16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1

(这16个数字是下划线部分)





3 3 2 13

5 10 11 8

9 6 7 12
4 15 14 1



行数:34 34 34 34

柱数:34 34 34 34
对角线总和:34 34











请使用最简单和最基本的方法解决问题。我上个月刚开始学习c语言。



上周,我们学习了条件声明。 (例如if-else,switch,goto)

(这就是为什么我认为这个问题可以用条件语句来解决?...)



非常感谢。



我尝试过:



我对c know不知道...

请帮助我..

解决方案

看起来CPalline做了一部分您的家庭作业,但您需要在某些 C-tutorial 中学习该语言并安装Visual Studio。



最简单的方法是用输入填充数组并进行数学运算。注意:数组以索引0开头。

  int  iArray [ 4 ] [ 4 ]; 
int number = iArray [ 2 ] [ 3 ]; // 第二行和第三列
// 提示使用函数进行计算,例如
int calcRowSum( int * arr, int 行)
{
int sum = 0 ;
for int i = 0 ; i< 4 ; i ++){
sum = sum + arr [row] [i];
}
return sum;
}


很抱歉,但本网站不提供订购代码或为您编写作业。如果您不理解作业或C语言,那么您需要与您的老师交谈。


我们不会做您的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!

首先将它分解为更简单的位:

1)输入:你知道如何为单个数字做这个,我敢肯定,所以只需要扩展16个数字。

2)存储:最简单的解决方案是一个4 x 4二维数组:

  int 数据[ 4  4 ]; 

用你的输入填写。所有你需要的是两个嵌套for循环,数据简单。

3)打印:数据很简单 - 再次有2个嵌套循环。

4)然后写两个函数:一个给出一行给定行号和数组,另一个给出一列给定列号和数组。每次打电话给他们四次,然后打印结果。

5)打印两个对角线的金额。



这并不复杂:只是做一点,测试它,然后继续下一步。如果你能做到这一点,把它分解成更小的部分并重复这个过程。这是一个简单的任务,真的!



如果您遇到特定问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!


Hello. As you can see I'm not english native speaker and not studying in US neither.(I know it's pretty obvious)

And my teacher gave me the assignment which is written in English and I've studied c language just for a month.

Still everything's so confusing to me.

It's my first time to visit the website, so if there's some kinda problem with my question, please forgive me.

And here's the question.




[2] Write a program that asks the user to enter the numbers from 1 to 16 (in any order) and then display the numbers in a 4 by 4 arrangement, followed by the sum of the rows, columns, and diagonals.

[An example input/output] underlined part is entered by the user

Enter the numbers from 1 to 16 in any order:
16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1
(those sixteen numbers are underline part)


16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1

Row sums: 34 34 34 34
Column sums: 34 34 34 34
Diagonal sums: 34 34





Please solve the problem using the easiest and basic way. I just started learning c language last month.

Last week, we learned conditional statement. (ex. if- else, switch, goto)
(And that's why I think this question can be solved using conditional statement?...)

Thank you very much.

What I have tried:

I know nothing about c

这篇关于我该如何解决这个问题?帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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