📄 u3.txt
字号:
1--------------------------------
#include <stdio.h>
void main()
{
int blank,digit,i,other,letter;
char ch;
blank=letter=digit=other=0;
printf("input 15 characters:\n");
for(i=1;i<=15;i++){
ch=getchar();
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
letter++;
else if(ch>='0'&&ch<='9')
digit++;
else if(ch=='\n')
blank++;
else
other++;
}
printf("enter=%d,digit=%d,other=%d,letter=%d",blank,digit,other,letter);
}
2--------------------------------
#include <stdio.h>
void main()
{
int choice,i;
float price;
for(i=1;i<=5;i++){
printf("[1]apples\n[2]pears\n[3]oranges\n[4]grapes\n[0]Exit\nEnter choice\n");
scanf("%d",&choice);
if(choice==0)
break;
switch (choice){
case 1:price=3.00;break;
case 2:price=2.50;break;
case 3:price=4.10;break;
case 4:price=10.20;break;
default:price=0;
}
printf("price=%.1f\n",price);
}
printf("Thanks\n");
}
}
3--------------------------------
#include <stdio.h>
void main()
{
int mark;
printf("input the mark:\n");
scanf("%d",&mark);
if(mark<60)
printf("Fail");
else printf("Pass");
}
4--------------------------------
#include <stdio.h>
#include <math.h>
void main()
{
float a,b,c,s;
printf("input a,b,c:\n");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
if(a+b>c&&a+c>b&&b+c>a)
printf ("area=%.2fperimeter=%5.2f",sqrt(s*(s-a)*(s-b)*(s-c)),2*s);
else printf("These sides do not correspond to availd triangle.\n");
}
5--------------------------------
#include <stdio.h>
void main()
{
int a,b,c,d,max;
printf("input a,b,c,d:\n");
scanf("%d%d%d%d",&a,&b,&c,&d);
max=a;
if(max<b)
max=b;
if(max<c)
max=c;
if(max=d)
max=d;
printf("max=%d",max);
}
6--------------------------------
#include <stdio.h>
void main()
{
float salary,rate,tax;
printf("input salary");
scanf("%f",&salary);
if(salary>5850)
rate=20;
else if(salary>2850)
rate=15;
else if(salary>1350)
rate=10;
else if(salary>850)
rate=5;
else rate=0
tax=rate*(salary-850)/100;
printf("tax=%f",tax);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -