當前位置:首頁 » 編程語言 » 一個人的c語言編程
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

一個人的c語言編程

發布時間: 2022-09-08 11:10:30

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++,進入如下界面: