
import javautilScanner;
public class $ {
private static int[] DAYS = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
public static void main(String[] args) {
Scanner in = new Scanner(Systemin);
Systemoutprint("输入年份:");
int year = innextInt();
Systemoutprint("输入月份:");
int month = innextInt();
String str = year + "-" + month + ":";
// 闰年二月份
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) && month == 2) {
str += 29;
} else {
str += DAYS[month - 1];
}
Systemoutprintln(str);
}
}
编写程序,输入一个月份值,输出该月份是第几季度,或者提示输入错误的C语言程序:
int main()
{int m;
scanf("%d",&m);
if(m<1||m>12)
printf("输入错误");
else
printf("第%d季度",(m-1)/3+1);
}
#include<stdioh>
int main()
{
charmonth_name[13]={"illegal month","January","February","March","April",
"May","June","July","August","September","October","November","December"};
int n;
printf("input month:\n");
scanf("%d",&n);
if((n<=12)&&(n>=1))
{
printf("it is %s\n",(month_name+n));
}
else
{
printf("it is wrong\n");
}
return 0;
}
扩展资料:
在计算机系统中,一条机器指令规定了计算机系统的一个特定动作。一个系列的计算机在硬件设计制造时就用了若干指令规定了该系列计算机能够进行的基本 *** 作,这些指令一起构成了该系列计算机的指令系统。
在计算机应用的初期,程序员使用机器的指令系统来编写计算机应用程序,这种程序称为机器语言程序。使用机器语言编写的程序,由于每条指令都对应计算机一个特定的基本动作,所以程序占用内存少、执行效率高。
缺点也很明显,如:编程工作量大,容易出错;依赖具体的计算机体系,因而程序的通用性、移植性都很差。
void main(){
int n;
char name[12]={"January","February","March","April","May","June","July","August","September","October","November","December"};
scanf("%d",&n);
printf("%s\n",name[n+1]);
}
以上就是关于编写程序,提示用户输入月份和年份,然后显示这个月份的天数.java语言编写全部的内容,包括:编写程序,提示用户输入月份和年份,然后显示这个月份的天数.java语言编写、编写程序,输入一个月份值,输出该月份是第几季度,或者提示输入错误、编一个程序,输入英文月份名,输出月份数字等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)