⑴ c语言编程,求一个人的年龄是多少。
第一行第一的是y0,你写成了yo
#include<stdio.h>
intmain()
{
inty0,m0,d0,y1,m1,d1,nianling;///////y0
printf("请输入您的生日:");
scanf("%d,%d,%d",&y0,&m0,&d0);
printf("请输入当前日期:");
scanf("%d,%d,%d",&y1,&m1,&d1);
nianling=y1-y0;
if(m1>m0)
{
if(d1>d0)
nianling--;
printf("%d",nianling);
}
else
printf("%d",nianling);
}
⑵ C语言编程,scanf输入一个人的名字,printf给出相应的评价
#include<stdio.h>
intmain(){
chars[100];
scanf("%s",s);
intn=s[0]%3;
switch(n){
case0:
printf("SB");
break;
case1:
printf("DB");
break;
case2:
printf("JB");
break;
}
return0;
}
⑶ C语言编程 如下
沿的编程是非常厉害,它是应用一个总程序软件的编程,所以势必要学的。
⑷ 输入一个人的出生年、月、日,再输入当前年、月、日,计算此人的实际年龄。用C语言编程,不用数组
#include<stdio.h>
typedefstructdate{
unsignedintyear;
unsignedintmonth;
unsignedintday;
}date;
intmain()
{
datebirthDay,now;
intage;
printf("dateformatisxxxx-xx-xx,suchas1993-01-01 ");
printf("inputbirthday ");
scanf("%d-%d-%d",&birthDay.year,&birthDay.month,&birthDay.day);
printf("inputcurrentdate ");
scanf("%d-%d-%d",&now.year,&now.month,&now.day);
age=now.year-birthDay.year;
printf("age:%d ",age);
return0;
}
⑸ 用C语言编写程序:输入一个人的名字、年龄、工资并在最后输出来。
struct imfomation{
char name[20];
int age;
int salary;
};
#include "stdio.h"
void main()
{
struct imfomation a;//a为结构体变量
printf("请输入姓名:\n");
gets(a.name);
printf("请输入年龄:\n");
scanf("%d",&a.age);
printf("请输入工资:\n");
scanf("%d",&a.salary);
printf("姓名:%s\n年龄:%d\n工资:%d\n",a.name,a.age,a.salary);
}
⑹ 求帮忙,c语言编程编个程序 一个人和电脑 ,20根木棍 ,轮流拿,可以拿1-3个 ,拿到最后一个的输, 需
#include<stdio.h>
#include<time.h>
#include<windows.h>
voidmain()
{
srand((unsigned)time(NULL));
intPerson;//人
intComputer;//电脑
intSTICK_NUMBER=20;//木棍有20条
intLOSS[2]={0};
while(true)
{
Person=Computer=0;
//人的操作
RESET_PERSON:
printf("[Person]:");
scanf("%d",&Person);
if(Person<1||Person>3)
{
printf("每次取木棍数只限于1~3根,请重新输入. ");
fflush(stdin);
gotoRESET_PERSON;
}
if(Person>=STICK_NUMBER){
LOSS[0]=1;//人输了
break;
}
elseSTICK_NUMBER-=Person;
//电脑的操作
printf(" ");
Computer=rand()%(3-1+1)+1;
Sleep(500);
printf("[Computer]:%d",Computer);
if(Computer>=STICK_NUMBER){
LOSS[1]=1;//电脑输了
break;
}
elseSTICK_NUMBER-=Computer;
fflush(stdin);
printf(" ");
}
if(LOSS[0])printf(" 人输出了 ");
elseprintf(" 电脑输出了 ");
}
⑺ C语言 写一个人简单的程序,我一菜鸟求助~
#include<stdio.h>
int main()
{
int a[10],i,max;
scanf("%d",&a[0]);
max = a[0];
for ( i = 0 ; i < 10 ; i++ )
{
scanf("%d",&a[i]);
if ( a[i] > max )
max = a[i];
}
printf("the max one is %d\n",max);
return 0;
}
⑻ 如何编写C语言程序
准备材料
windows电脑、VC++(DEV_C++)
1.打开桌面上的DEV_C++,进入如下界面: