2, the expression for the amount of logic 1 for true and 0 for false.
For a logical expression amount of non-zero for true, 0 for false.
3, it is worth noting that c language priorities, in descending order of priority:
4、
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,c,t; 5 scanf("%d,%d,%d",&a,&b,&c); 6 if(a<b) 7 {t=b; 8 a=b; 9 b=t;} 10 if(a<c) 11 {t=c; 12 a=c; 13 c=t;} 14 printf("最大的是:%d\n",a); 15 return 0; 16 }
Method 2:
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,c,temp,max; 5 scanf("%d,%d,%d",&a,&b,&c); 6 temp=(a>b)?a:b; 7 max=(temp>c)?temp:c; 8 printf("最大的是:%d\n",max); 9 return 0; 10 }
5、
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int a,b; 6 scanf("%d",&a); 7 if(a>=1000) 8 {printf("enter again:\n"); 9 scanf("%d",&a);} 10 b=sqrt(a); 11 printf("%d\n",b); 12 return 0; 13 }
8、
1 #include<stdio.h> 2 int main() 3 { 4 float score; 5 char grad; 6 printf("enter score:"); 7 scanf("%f",&score); 8 while(score>100||score<0) 9 {printf("enter again:"); 10 scanf("%f",&score); 11 } 12 switch((int)(score/10)) 13 {case 10: 14 case 9:grad='A';break; 15 case 8:grad='B';break; 16 case 7:grad='C';break; 17 case 6:grad='B';break; 18 case 5: . 19 Case . 4 : 20 is Case . 3 : 21 is Case 2 : 22 is Case . 1 : 23 is Case 0 : Grad = ' E ' ; 24 } 25 the printf ( " performance is:% 5.1f, rating is: C% \ n- " , Score, Grad); 26 is return 0 ; 27 }
9, gave a positive integer of not more than five, Austrian ball
It is determined few, are out of each digit, the digits in reverse order output
. 1 #include <stdio.h> 2 #include <math.h> . 3 int main () . 4 { 5 int NUM, INDIV, Ten, Hundred, Thousand, ten_thousand, Place; . 6 the printf ( " Enter a not more than 5 bit integer: " ); . 7 Scanf ( " % D " , & NUM); . 8 IF (NUM> 9999 ) . 9 Place = . 5 ; 10 the else . 11 IF (NUM> 999 ) 12 is Place = . 4 ; 13 is the else 14 IF (NUM> 99 ) 15 Place = . 3 ; 16 the else . 17 IF (NUM> . 9 ) 18 is Place = 2 ; . 19 the else 20 is Place = . 1 ; 21 is the printf ( " median:% D \ n- " , Place); 22 is the printf ( " each digit of \ n- " ); 23 is ten_thousand NUM = / 10000 ; 24 thousand=(int)(num-ten_thousand*10000)/1000; 25 hundred=(int)(num-ten_thousand*10000-thousand*1000)/100; 26 ten=(int)(num-ten_thousand*10000-thousand*1000-hundred*100)/10; 27 indiv=(int)(num-ten_thousand*10000-thousand*1000-hundred*100-ten*10); 28 Switch (Place) 29 { 30 Case . 5 : the printf ( " % D,% D,% D,% D,% D " , ten_thousand, Thousand, Hundred, Ten, INDIV); 31 is the printf ( " \ n-reverse order number is \ n- " ); 32 the printf ( " % D% D% D% D% D " , INDIV, Ten, Hundred, Thousand, ten_thousand); 33 is BREAK ; 34 is Case . 4 : the printf ( " % D,% D,% D ,% D " , Thousand, Hundred, Ten, INDIV); 35 the printf ( " \ n-number in reverse order of \ n- " ); 36 the printf ( " % D% D% D% D " , INDIV, Ten, Hundred, Thousand); 37 [ BREAK ; 38 is Case . 3 : the printf ( " % D,% D,% D " , Hundred, Ten, INDIV); 39 the printf ( " \ n-reversed order number is \ n- " ); 40 the printf ( " % D% D% D " , INDIV, Ten, Hundred); 41 is BREAK ; 42 is Case 2 : the printf ( " % D,% D " , Ten, INDIV); 43 is the printf ( " \ n-number in reverse order of \ n- " ); 44 the printf ( " % D% D " , INDIV, Ten); 45 BREAK ; 46 is Case . 1 : the printf ( " % D " , INDIV); 47 the printf ( " \ n-reversed order number is \ n- " ); 48 the printf ( " D% " , INDIV); 49 BREAK ; 50 } 51 is return 0 ; 52 is }
12, it is determined whether the outer column
1 #include<stdio.h> 2 int main() 3 { 4 int h=10; 5 float x1=2,y1=2,x2=-2,y2=2,x3=-2,y3=-2,x4=2,y4=-2,x,y,d1,d2,d3,d4; 6 printf("请输入x,y: "); 7 scanf("%f,%f",&x,&y); 8 d1=(x-x4)*(x-x4)+(y-y4); 9 d2=(x-x1)*(x-x1)+(y-y1)*(y-y1); 10 d3=(x-x2)*(x-x2)+(y-y2)*(y-y2); 11 d4=(x-x3)*(x-x3)+(y-y3)*(y-y3); 12 if(d1>1&&d2>1&&d3>1&&d4>1) 13 h=0; 14 printf("高度为:%d\n",h); 15 return 0; 16 }