プロが教える店舗&オフィスのセキュリティ対策術

プログラミング初心者で先日初めてプログラミングに触れました。課題が出されたのですが、全くわからず期限までに提出できませんでした。教えていただけますか?
出された課題は:
Create a program by solving subtasks described below. The program must have two input parameters: integers a and b. If a=3 and b=5, then the final output of the program must be the following:

Enter value of a: 3
Enter value of b: 5
You entered the following values: a = 3 and b = 2.
If 3 and 5 are dimensions of a rectangle, then its perimeter is 16.
If 3 and 5 are legs of a right triangle, then its area is 7.5.
It is False that 5 is a two-digit number.
The last two digits of number 1015 are 1 and 5.

Subtasks
There are 5 subtasks each of which worths 2 points out of 10. It is allowed to skip some subtasks or leave some subtasks incomplete, but the maximal grade is possible when all subtasks are completely solved.

1. Ask the user to enter two integers and store them in variables a and b. Print values of a and b. The output of the program must be the following:

Enter value of a: 3
Enter value of b: 5
You entered the following values: a = 3 and b = 2.
Here values 3 and 5 are given by the user.

2. Consider a and b are dimensions of a rectangle and calculate its perimeter

P = 2 ( a + b )
The output of the program must be the following:

If 3 and 5 are dimensions of a rectangle, then its perimeter is 16.

Here values 3 and 5 are given by the user.

3. Consider a and b are legs of a right triangle and calculate its area:

S = a × b /2
The output of the program must be the following:

If 3 and 5 are legs of a right triangle, then its area is 7.5.

Here values 3 and 5 are given by the user.

4. Check whether the value of a is a two-digit number or not (larger than 9 and lower than 100). If a is a two-digit number (e.g. 32), then print

It is True that 32 is a two-digit number.
If a is not a two-digit number (e.g. 5), then print
It is False that 5 is a two-digit number.

5. Print two last digits of a number

c = 1000 + a × b
If a=3 and b=5, then the output of the program must be the following:

The last two digits of number 1015 are 1 and 5.

質問者からの補足コメント

  • つらい・・・

    正直わたしの勉強不足です、、、。お恥ずかしいことに何をどうしていいか全くわからず今必死にぐぐっているのですが混乱しています、、、。

    No.1の回答に寄せられた補足コメントです。 補足日時:2018/10/18 16:29

A 回答 (7件)

単純に端末からの入力、数値計算、大小判定、端末への出力、これだけが求められている課題ですね。



全く分からない(何が分からないのか分からない)のであれば、担当教員に質問しに行って納得いくまで説明してもらうか、来年も履修するかの二択だと思います。ググっても何も得られないでしょう。
    • good
    • 1

はじめて触る初心者がやるような課題ではない。



分からなくて当然です。

課題を出した奴に訊きましょう。
    • good
    • 1

あとね、うーん・・・・英語読めるんですかね?なんで英語での「課題」になってるのか良く分からんのですが。


この「課題」ってのは「あるプログラムを作れ」とは言ってるんだけど、「以下の5つの"サブタスク"をこなせば必然的に"課題のプログラム"は完成する筈だ」って書いてるんですよ。つまり、「誘導型の問題」であって・・・「全部分かんねぇ」ってなるわけがないんです。
仮に「全部分かんねぇ」となるとなると・・・・そりゃよっぽどの事だろ、って事ですね(全く授業聞いてないとか、理解出来てないとか、「仮に海外の大学で学んでるなら」素直にドロップすれば良いレベルです)。

一応日本語で意訳書いておきますが、

サブタスク1: aとbに入力された数値を割り振り、それらを表示せよ。
サブタスク2: 入力された数値a、bを長方形の高さと幅と見做す時、長方形の周囲の長さを求めよ -> 算数的に2*(a + b)になるのは「自明」。
サブタスク3: 入力された数値a、bを直角三角形の高さと幅と見做す時、面積を求めよ -> これも小学校の算数
サブタスク4: 数値aが二桁の数かどうか判定し、それに従って(省略)をプリントせよ。
サブタスク5: c = 1000 + a × bを計算して、下二桁の数をそれぞれプリントせよ。 -> ぶっちゃけ1000足すのは全く関係ないと思う(笑)。

殆ど「小学校の算数」なんで、ひねりもクソもなくって、「プログラミングがどーの・・・」ってレベルじゃあないんですよねぇ。
    • good
    • 2

ちょっと気になる事があるんですが。



> Enter value of a: 3
> Enter value of b: 5
> You entered the following values: a = 3 and b = 2.

aに3入力してbに5を入力するんだけど、表示で「b=2」ってのはそもそもどういう事なんですかね?
テキストの誤植なんですか、それとも入力に5を受け付けても b = b - aって演算を行え、って事なんですか?
    • good
    • 0

本当に手も足も出ない、最初の1行目も書けないという場合、学校での勉強なのでしたらまずは教科書に沿って最初から勉強しなおしましょう。


そうではなく問題の意味がわからなかったり、プログラムの処理手順(アルゴリズム)を自然言語(日本語や英語)で箇条書きに出来ないということでしたら、具体的に何が(or何処が)わからないのかを明確にしましょう。
なお、英語が訳せないのでしたら辞書を引きましょう。

また、「わからないから未提出」ではなく、わからなかったら担当の先生に質問しましょう。
参考まで。
    • good
    • 2

>お恥ずかしいことに何をどうしていいか全くわからず今必死にぐぐっているのですが混乱しています、、、。


まぁとりあえず
お決まりの呪文があるはずです

#include <stdio.h>

int main(void)
{

}

これは欠かせません

で、キーボードからの入力の受付はscanf
画面への文字の出力はprintf

多分これだけあれば問題のプログラムは作れると思います
scanfやprintfで検索すれば使い方は沢山出てきます
    • good
    • 1

>全くわからず期限までに提出できませんでした。

教えていただけますか?
全く分からずというのは
一行も書くことができなかったということですか?
そんなわけは無いと思いますから
せめてどこまで出来てどこが分からなかったのかとかを教えていただけると
やりやすいのですが
この回答への補足あり
    • good
    • 1

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!