java基础课程第四章_第四章丶Java教程网-IT开发者们的技术天堂

第一题

#include

#include

int main() {

int hour12,hour24,minute;

char am_pm;

putchar("Enter a 12-hour time:");

scanf("%d:%d %c",&hour12,&minute,&am_pm);

hour24=hour12%12;

if (toupper(am_pm)=='p')

hour24+=12;

printf("Equivalent 24-hour time:%d.2d:.2d\n",hour24,minute);

return 0;

}

第二题

#include

#include

int main() {

char ch;

int num_vowels=0;

printf("Enter a sentence:");

while ((ch=getchar())!='\n'){

switch (toupper(ch)) {

case 'A':

case 'E':

case 'I':

case 'O':

case 'U':

num_vowels++;

}

}

printf("Your sentence contains %d vowels.",num_vowels);

return 0;

}

be083c00198fd47cfb240763cdd24dc1.png

第三题

#include

int main() {

char first_inital,ch;

printf("Enter a first and last name:");

scanf("%c",&first_inital);

while (getchar()!=' '){

while ((ch=getchar())!='\n'){

if(ch!=' ')

putchar(ch);

}

}

printf(",%c.\n",first_inital);

return 0;

}

c35dfd2829368a3f6f32f3beedce1223.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值