C语言作业 实在不会做了 求大神帮忙!!!多谢!!!
Theprogramitselfasksforyourfirstandlastnames,andreportstotalnumberoflettersinthem.#in...
The program itself asks for your first and last names, and reports total number of letters in them.
#include <stdio.h>
#include <string.h>
struct namect
{
char fname[20];
char lname[20];
int letters;
};
void getinfo(struct namect *pst);
void makeinfo(struct namect *pst);
void showinfo(struct namect *pst);
int main()
{
struct namect person;
getinfo(&person);
makeinfo(&person);
showinfo(&person);
return 0;
}
make these 3 functions by your own and make the program work. (prototypes are listed below)
void getinfo(struct namect *pst);
void makeinfo(struct namect *pst);
void showinfo(struct namect *pst);
Input:
Please enter your first name.
Viola
Please enter your last name.
Plunderfest
Output:
Viola Plunderfest, your name contains 16 letters. 展开
#include <stdio.h>
#include <string.h>
struct namect
{
char fname[20];
char lname[20];
int letters;
};
void getinfo(struct namect *pst);
void makeinfo(struct namect *pst);
void showinfo(struct namect *pst);
int main()
{
struct namect person;
getinfo(&person);
makeinfo(&person);
showinfo(&person);
return 0;
}
make these 3 functions by your own and make the program work. (prototypes are listed below)
void getinfo(struct namect *pst);
void makeinfo(struct namect *pst);
void showinfo(struct namect *pst);
Input:
Please enter your first name.
Viola
Please enter your last name.
Plunderfest
Output:
Viola Plunderfest, your name contains 16 letters. 展开
1个回答
展开全部
看代码:
#include <stdio.h>
#include <string.h>
struct namect
{
char fname[20];
char lname[20];
int letters;
};
void getinfo(struct namect *pst);
void makeinfo(struct namect *pst);
void showinfo(struct namect *pst);
int main()
{
struct namect person;
getinfo(&person);
makeinfo(&person);
showinfo(&person);
return 0;
}
void getinfo(struct namect *pst)
{
printf ("Please enter your first name.\n");
scanf ("%s", pst->fname);
printf ("Please enter your last name.\n");
scanf ("%s", pst->lname);
}
void makeinfo(struct namect *pst)
{
pst->letters = strlen(pst->fname) + strlen(pst->lname);
}
void showinfo(struct namect *pst)
{
printf ("%s %s,your name contains %d letters\n", pst->fname, pst->lname, pst->letters);
}
运行:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |