/*
NOJ
之文件篇
*/
#include <stdio.h>
int main(){
FILE *in, *out; //创建文件的变量(指针)
in = fopen("DATA.txt", "r"); //用 in 以"read"形式打开"DATA.txt"文件
char ch[100];
fgets(ch, 100, in); //从 in 读取 100 个字符到 ch
while(fgets(ch, 100, in)){ //循环输入 100 长度的,直到全部输入,就是一个循环结构
printf("%s", ch);
}
使用字符串方法处理字符串
out = fopen("DATA_out.txt", "w");//用 out 以"write"形式打开"DATA_out.txt"文件
fprintf(out, ch); //把 ch 写进 out 所代表的文件
return 0;
}
/*
NOJ math
函数
*/
#include <stdio.h>
#include <math.h>
#define PI 3.14159
int main(){
int b = pow(2,2); //指数函数,b 等于 2 的 2 次方
double a = 30;//角度:30 度
//sin(), cos(), tan()的输入为弧度制
//需要将角度除以 PI 转化为弧度制
printf("sin = %lf", sin(a/180*PI));
printf("cos = %lf", cos(a/180*PI));
printf("tan = %lf", tan(a/180*PI));
}