Auto commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
if(条件){
|
||||
复合语句(条件为真时执行)
|
||||
}else{
|
||||
复合语句(条件为假时执行)
|
||||
}
|
||||
*/
|
||||
int main(void){
|
||||
|
||||
int x, y, z, t;//定义三个整型变量
|
||||
//数据类型 变量名1, 变量名2;
|
||||
scanf("%d%d%d", &x, &y, &z);
|
||||
if(x > y){
|
||||
t = x;
|
||||
x = y;
|
||||
y = t;
|
||||
}//实现x和y比较 大数放y位置
|
||||
if(y > z){
|
||||
t = y;
|
||||
y = z;
|
||||
z = t;
|
||||
}//实现y和z比较 大数放z位置 z为三个数字中最大数
|
||||
if(x > y){
|
||||
t = x;
|
||||
x = y;
|
||||
y = t;
|
||||
}
|
||||
printf("%d %d %d\n", x, y, z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void){
|
||||
|
||||
|
||||
int a;
|
||||
|
||||
scanf("%d", &a);
|
||||
printf("该数的位数为%d\n",
|
||||
(a/10==0?1:(a/100==0?2:(a/1000==0?3:(a/10000==0?4:5)))));
|
||||
printf("%d", a%10);
|
||||
if(a%100/10 != 0){
|
||||
printf("%d", a%100/10);
|
||||
}
|
||||
if(a%1000/100 != 0){
|
||||
printf("%d", a%1000/100);
|
||||
}
|
||||
if(a%10000/1000 != 0){
|
||||
printf("%d", a%10000/1000);
|
||||
}
|
||||
if(a/10000 != 0){
|
||||
printf("%d", a/10000);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void){
|
||||
|
||||
float a, b, result;
|
||||
int flag;
|
||||
printf("请输入两个数字:");
|
||||
scanf("%f %f", &a, &b);
|
||||
printf("请输入您要进行的操作(1.做加法 2.做乘法 3.做除法):");
|
||||
scanf("%d", &flag);
|
||||
switch(flag){
|
||||
case 1:result = a+b;break;
|
||||
case 2:result = a*b;break;
|
||||
case 3:result = a/b;break;
|
||||
}
|
||||
printf("结果为%f\n", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void){
|
||||
|
||||
int year, month, day, days=0;
|
||||
|
||||
scanf("%d-%d-%d", &year, &month, &day);
|
||||
days+=day;
|
||||
//1 3 5 7 8 10 12
|
||||
//从前一个月开始依次
|
||||
switch(month-1){
|
||||
case 11:days+=30;
|
||||
case 10:days+=31;
|
||||
case 9:days+=30;
|
||||
case 8:days+=31;
|
||||
case 7:days+=31;
|
||||
case 6:days+=30;
|
||||
case 5:days+=31;
|
||||
case 4:days+=30;
|
||||
case 3:days+=31;
|
||||
case 2:days+=28;
|
||||
case 1:days+=31;
|
||||
}
|
||||
if(month>3 && (year%4==0&&year%100!=0 || year%400==0)){
|
||||
days++;
|
||||
}
|
||||
printf("%d\n", days);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
1.解决字符的循环输入
|
||||
while((ch=getchar())!='\n')
|
||||
|
||||
2.判断字符类型
|
||||
ASCALL码范围
|
||||
|
||||
*/
|
||||
int main(){
|
||||
|
||||
char ch;
|
||||
int l, d, o;//l字母的个数 d为数字个数 o为其他字符个数
|
||||
l=d=o=0;
|
||||
while((ch=getchar()) != '\n'){
|
||||
if(ch >= 'a' && ch<='z' || ch >= 'A' && ch<='Z' ){
|
||||
l++;
|
||||
}else if(ch >= '0' && ch <= '9'){
|
||||
d++;
|
||||
}else{
|
||||
o++;
|
||||
}
|
||||
}
|
||||
printf("字母个数:%d 数字个数:%d 其他个数%d\n", l, d, o);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user