/ex06prime.c Secret
Last active
October 14, 2017 07:00
2017年度応用プログラミング及び実習 ex06D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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