要求:

1.显示系统时间

2.绘制系统图案

3.输入用户名和密码,并保存到data.txt文件中

 
//define.h #ifndef _DELINE_H #define _DELINE_H #include <stdio.h> #include
<time.h> #include <string.h> #include <stdlib.h> //显示系统时间 void showtime();
//绘制心形 void paintheart(); //输入用户名 int scanfuser(); //输入密码 int scanfpassword();
#endif //showtime.cpp #include "define.h" void showtime() { time_t timep; char
s[30]; time(&timep); strcpy(s,ctime(&timep)); printf("%s", s); }
//paintheart.cpp #include "define.h" void paintheart() { //心形函数 for (float y =
1.5f; y > -1.5f; y -= 0.1f) { for (float x = -1.5f; x < 1.5f; x += 0.05f) {
float a = x * x + y * y - 1; putchar(a * a * a - x * x * y * y * y <= 0.0f ?
'*' : ' '); } putchar('\n'); } } //scanfuser.cpp #include "define.h" int
scanfuser() { //定义用户名数组 char user[100]; //打印文字 printf("用户名:");
//输入用户名并保存到user数组中 scanf("%s",user); //printf("%s",user);
//将用户名信息保存在data.txt文件中 FILE *fpWrite=fopen("data.txt","a+"); //成功创建文件时
if(fpWrite) { //不为空时逐个字符保存 for(int i=0;user[i]!='\0';i++) {
fprintf(fpWrite,"%c",user[i]); } //关闭文件 fclose(fpWrite); //释放指针 fpWrite=NULL; }
return 0; } //scanfpassword.cpp #include "define.h" int scanfpassword() {
//声明密码数组 char password[100]; //打印文字 printf("密码:"); //输入密码并保存到数组中
scanf("%s",password); //printf("%s",password); //将用户名信息保存在data.txt文件中 FILE
*fpWrite=fopen("data.txt","a+"); //成功创建文件时 if(fpWrite) { //不为空时逐个字符保存 for(int
i=0;password[i]!='\0';i++) { fprintf(fpWrite,"%c",password[i]); } //关闭文件
fclose(fpWrite); //释放指针 fpWrite=NULL; } return 0; } //main.cpp #include
"define.h" int main() { //更改标题 system("title 登录界面"); //设置屏幕为白底红字 system("color
f4"); //设置窗口大小为80×40 system("mode con cols=80 lines=40"); //显示系统时间 showtime();
//绘制心形图案 paintheart(); //换行居中 printf("\n "); //输入用户名 scanfuser(); //换行居中
printf("\n "); //输入密码 scanfpassword(); return 0; }


 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信