Skip to content

Instantly share code, notes, and snippets.

@takatakamanbou
Last active October 14, 2017 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takatakamanbou/6515c6450f85de524050afdb3191d2e0 to your computer and use it in GitHub Desktop.
Save takatakamanbou/6515c6450f85de524050afdb3191d2e0 to your computer and use it in GitHub Desktop.
2017年度応用プログラミング及び実習 ex06D
#include <stdio.h>
#include <stdlib.h>
#define FNAME "primedata.txt"
#define NDATA 100
int main(void)
{
int x[NDATA], y = 106483, n;
FILE *fp;
// MaxDivisor() を使ってみる
printf("%d の約数のうち %d を除いて最大なのは %d です\n", y, y, ★★★);
// ファイルから数を読み込む
fp = fopen(FNAME, "r");
if(fp == NULL){
fprintf(stderr, "ERROR: fopen failed\n");
exit(EXIT_FAILURE);
}
for(n = 0; n < NDATA; n++){
if(★★★ != fscanf(fp, "%d", &x[n])) break;
}
fclose(fp);
printf("%d 個読み込みました\n", ★★★);
// PrintPrime() を使ってみる
printf("----------\n");
PrintPrime(★★★);
printf("----------\n");
// CountPrime() を使ってみる
printf("この中に素数は %d 個あります\n", ★★★);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment