Ⅰ c语言结构体 建立一份同学通讯录,包含姓名、电话、通信地址、邮编、生日等信息,要求按姓名的字母顺序排
你对结构体中的子结构体的赋值也是不对的……
等我看看怎么改比较好……
改成这样:
#include<stdio.h>
#include<string.h>
struct data
{
int month;
int day;
int year;
};
struct stud
{
char name[20];
char tele[12];
char zip[7];
struct data birthday;
char addre[30];
};
/*{*/
int main()
{
//birthday是个整体,要加{}给birthday赋值
struct stud stu[30]={
"Liming","123456789","216546",{3,14,2001},"beijing",
"Xavi","789456123","216549",{4,5,2009},"tianjing",
"Messi","894564613","121487",{12,1,1993},"shanghai"};
int k,i,j,n=3;
struct stud temp;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(strcmp(stu[j].name,stu[k].name)<0)
k=j;
temp=stu[i];
stu[i]=stu[k];
stu[k]=temp;
}
printf("姓名 电话 邮编 生日 地址 ");
for(i=0;i<3;i++)
printf("%10s%12s%8s %2d-%2d-%4d %15s ",stu[i].name,stu[i].tele,stu[i].zip,stu[i].birthday.month,stu[i].birthday.day,stu[i].birthday.year,stu[i].addre);//少了电话……
return 0;
}
仔细调试啊,少年……
自己调试才能提高自己的编程能力。
为你解决疑问其实就是调试的过程,也是我学习的过程。
傍晚好,少年!

Ⅱ 哪位仁兄可以用C语言帮我写一个生日快乐的小程序 就是已输入生日 最后可以出现生日蛋糕的图像
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const int inf=0xfffffff ;
int preminv[21] ;
int ri[21],hi[21] ;
int total,floornum ;
int ans ;
int dfs (int n,int v,int s,int maxr,int maxh)
{
int res ;
int i,tmpr,tmph,tmpsum ;
if (n>floornum){
if (v==total && s+ri[1]*ri[1]<ans){
ans = s+ri[1]*ri[1] ;
return 1 ;
}
}
for (ri[n]=maxr-1 ; ri[n]>=floornum-n+1 ; ri[n]--){
res = 2.0*(total-v)/ri[n] + ri[1]*ri[1] ;
if (res + s >= ans) continue ;
for (hi[n]=maxh-1 ; hi[n]>=floornum-n+1 ; hi[n]--){
if (v+ri[n]*ri[n]*hi[n]+preminv[floornum-n]>total) continue ;
tmpr = ri[n] ,tmph = hi[n],tmpsum = 0 ;
for (i=n ; i<=floornum ; i++){
tmpsum += tmpr*tmpr*tmph ;
tmpr-- , tmph-- ;
}
if (v+tmpsum<total) continue ;
dfs(n+1,v+ri[n]*ri[n]*hi[n],s+2*ri[n]*hi[n],ri[n],hi[n]) ;
}
}
return 1 ;
}
int main()
{
int tmpv,tmpr,tmph ;
int i ;
tmpv=0 ;
for (i=1 ; i<21 ; i++){
tmpv += i*i*i ;
preminv[i] = tmpv ;
}
while (scanf("%d%d",&total,&floornum)!=EOF){
ans = inf ;
tmpv = total - preminv[floornum-1] ;
if (tmpv>0){
tmpr = sqrt (1.0*tmpv/floornum) + 1 ;
tmph = 1.0*tmpv/(floornum*floornum) + 1 ;
dfs(1,0,0,tmpr,tmph) ;
}
if (ans==inf){
ans = 0 ;
}
printf("%d\n",ans) ;
}
return 0;
}
Ⅲ 如何用C语言编写一个程序,输入你的姓名和年龄并输出
#include <stdio.h>
int main(void)
{
char name[20];
int age;
printf("请输入你的姓名:");
scanf("%s",name);
printf("请输入你的年龄:");
scanf("%d",&age);
printf("你的姓名是:%s\n",name);
printf("你的年龄是:%d\n",age);
return 0;
}
Ⅳ 谁能写一个蛋糕程序,用C语言。财富值可以再加。
你可以用*号来做啊,就是不停的输出*,最后构成蛋糕。
Ⅳ C语言编程:定义一个名为student_record的结构体,它包含学生姓名、学号和出生日期。
struct date { int day ; int month; int year }; struct student_record { char name[10]; struct date birthday; int score; }
Ⅵ 怎么用C语言程序做个生日蛋糕,能做可以动的嘛
需要图形包比如opengl,当然可以做动的。不过干嘛这么麻烦呢,随便用个建模软件做不是更方便
Ⅶ C语言编程,定义包含学号、姓名和成绩的学生信息结构类型,完成以下功能:
代码如下:
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#defineMAX50
typedefstruct{
charstuId[10];
charname[20];
intscore;
}Student;
voidinput(Studentstudents[MAX],intn)
{
inti;
for(i=0;i<n;i++){
scanf("%s",students[i].stuId);
scanf("%s",students[i].name);
scanf("%d",&students[i].score);
}
}
voidsort(Studentstudents[MAX],intn)
{
inti,j;
Studenttemp;
for(i=0;i<n-1;i++){
for(j=0;j<n-i-1;j++){
if(students[j].score<students[j+1].score){
memcpy(&temp,&students[j],sizeof(Student));
memcpy(&students[j],&students[j+1],sizeof(Student));
memcpy(&students[j+1],&temp,sizeof(Student));
}
}
}
}
voidprint(Studentstudents[MAX],intn)
{
inti;
for(i=0;i<n;i++){
printf("%s%s%d ",students[i].stuId,students[i].name,students[i].score);
}
}intmain()
{
Studentstudents[MAX];
intn;
scanf("%d",&n);
input(students,n);
sort(students,n);
printf("输出: ");
print(students,n);
system("pause");
return0;
}
运行结果:

Ⅷ C语言 怎么用count做个生日蛋糕
用数组画好图案然后输出即可
Ⅸ 如何用C语言编写自己的姓名和学号
可以参考下面的代码:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp=fopen("data.txt","r");
if (!fp)
{
fp=fopen("data.txt","w");
printf("请输入姓名:");
char *name;
scanf("%s",name);
printf("请输入学号:");
char *num;
scanf("%s",num);
fprintf("%s %s",name,num);
fclose(fp);
return 0;
}
char *name,*num;
fscanf("%s %s",name,num);
fclose(fp);
printf("姓名为:%s 学号为:%s",name,num);
return 0;
}

(9)c语言编程能加姓名的生日蛋糕扩展阅读:
1、printf()函数
printf()函数是格式化输出函数, 一般用于向标准输出设备按规定格式输出
信息。在编写程序时经常会用到此函数。函数的原型为:
int printf(const char *format, ...);
函数返回值为整型。若成功则返回输出的字符数,输出出错则返回负值。
2、scanf()
函数 scanf() 是从标准输入流stdin(标准输入设备,一般指向键盘)中读内容的通用子程序,可以说明的格式读入多个字符,并保存在对应地址的变量中。
Ⅹ c语言 编程
#include <stdio.h>
int main()
{
unsigned long birth;
char name[50];
float age;
scanf("%lu %s %f",&birth,name,&age);
printf("%lu %s %f",birth,name,age);
return 0;
}

