P2433 [Shenji 1-2] Primary School Mathematics N in One

primary Mathematics

Yesterday, I just came into contact with Luogu under the introduction of my classmates. I feel that the above questions are very good. Although some of the questions are a bit unfriendly to novices, I believe that learning them step by step will definitely overcome them.

#include<stdio.h>
#include<math.h>
main()
 {
    
    int T;
  scanf("%d",&T);
    if (T == 1) {
    
    
        printf("I love Luogu!");
    } else if (T == 2) {
    
    
       printf("%d %d",2+4,10-2-4);
    } else if (T == 3) {
    
    
        printf("%d\n%d\n%d",14/4,14-(14%4),14%4);
    } else if (T == 4) {
    
    
        printf("%.3f",(float)500/3);
    } else if (T == 5) {
    
    
         printf("%d",(260+220)/32);
    } else if (T == 6) {
    
    
         printf("%.4f",sqrt(6*6+9*9));
    } else if (T == 7) {
    
    
        printf("%d\n%d\n%d",100+10,100+10-20,0);
    } else if (T == 8) {
    
    
        printf("%.4f\n%.4f\n%.3f",2*5*3.141593,3.141593*5*5,3.141594*5*5*5*4.0/3);
    } else if (T == 9) {
    
    
        int peach=1,i;
        for(i=0;i<3;i++)
        {
    
       
        	peach = (peach+1)*2;	
		}
		printf("%d",peach);
    } else if (T == 10) {
    
    
        printf("9");
//        x+30y=30×8
//		x+6y=6×10
    } else if (T == 11) {
    
    
        printf("%.4f",1.0*100/3);
    } else if (T == 12) {
    
    
        printf("%d\n%c",('M'-'A'+1),('A'+18-1));
    } else if (T == 13) {
    
    
         printf("%d",(int)pow(4.0/3*3.141593*(4*4*4+10*10*10),1.0/3));
    } else if (T == 14) {
    
    
    	int ans[2],res;
		int j = 0;
		for (int i = 0; i < 100; i++)
		{
    
    
			if ((110 - i) * (10 + i) == 3500)
			{
    
    
				ans[j++] = 110 - i;
			}
		}
		if (ans[0] >= ans[1])
			{
    
    
				res = ans[1];
			}
		else
			{
    
    
				res = ans[0];
			}

        printf("%d",res);
    }

}

If you get an error saying that the result is too long, just keep seven significant digits!
Finally, you can see where is wrong. There are specific rows and columns. After read is your value, after expect is the value expected by the system.
If you don’t know the type, try to use floating point types!
Force conversion (float), or *1.0.
Probably only these.
Super Mario output all / you can keep the spaces from disappearing.
Give yourself a like every day!

Guess you like

Origin blog.csdn.net/m0_51465487/article/details/115283273
Recommended