1 / 3

課題1

課題1. 先週のサンプルプログラム4(ファイルへの出力)を Web からダウンロードし、出力するファイル名を「 #define 」を使ってプログラムの先頭で指定しなさい。 条件 ファイルをオープンするところが fp=fopen(FNAME,"w"); のようになる。 (FNAME でなくてもよい ). 課題2. 二乗を計算する関数を用いて、 1 から n までの二乗を表示するプログラムを作りなさい。 条件 nは実行後に入力する 実行例 >a.exe n: 3 1*1 = 1 2*2 = 4 3*3 = 9. 二乗を計算する関数.

trula
Download Presentation

課題1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 課題1 • 先週のサンプルプログラム4(ファイルへの出力)をWebからダウンロードし、出力するファイル名を「#define」を使ってプログラムの先頭で指定しなさい。 • 条件 • ファイルをオープンするところが fp=fopen(FNAME,"w"); のようになる。(FNAMEでなくてもよい)

  2. 課題2 • 二乗を計算する関数を用いて、1からnまでの二乗を表示するプログラムを作りなさい。 • 条件 • nは実行後に入力する • 実行例 >a.exe n: 3 1*1 = 1 2*2 = 4 3*3 = 9

  3. 二乗を計算する関数 void jijo(int n, int *a) { int i; for (i=0; i<n; i++) { a[i] = (i+1)*(i+1); } } • ヒント • aの添え字が1ずれている • a[0] = 1*1 = 1 • a[1] = 2*2 = 4 • a[2] = 3*3 = 9

More Related