12 条题解

  • 1
    @ 2024-11-20 13:46:01
    #pragma GCC optimize(3)
    #pragma GCC target("avx")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("inline")
    #pragma GCC optimize("-fgcse")
    #pragma GCC optimize("-fgcse-lm")
    #pragma GCC optimize("-fipa-sra")
    #pragma GCC optimize("-ftree-pre")
    #pragma GCC optimize("-ftree-vrp")
    #pragma GCC optimize("-fpeephole2")
    #pragma GCC optimize("-ffast-math")
    #pragma GCC optimize("-fsched-spec")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("-falign-jumps")
    #pragma GCC optimize("-falign-loops")
    #pragma GCC optimize("-falign-labels")
    #pragma GCC optimize("-fdevirtualize")
    #pragma GCC optimize("-fcaller-saves")
    #pragma GCC optimize("-fcrossjumping")
    #pragma GCC optimize("-fthread-jumps")
    #pragma GCC optimize("-funroll-loops")
    #pragma GCC optimize("-fwhole-program")
    #pragma GCC optimize("-freorder-blocks")
    #pragma GCC optimize("-fschedule-insns")
    #pragma GCC optimize("inline-functions")
    #pragma GCC optimize("-ftree-tail-merge")
    #pragma GCC optimize("-fschedule-insns2")
    #pragma GCC optimize("-fstrict-aliasing")
    #pragma GCC optimize("-fstrict-overflow")
    #pragma GCC optimize("-falign-functions")
    #pragma GCC optimize("-fcse-skip-blocks")
    #pragma GCC optimize("-fcse-follow-jumps")
    #pragma GCC optimize("-fsched-interblock")
    #pragma GCC optimize("-fpartial-inlining")
    #pragma GCC optimize("no-stack-protector")
    #pragma GCC optimize("-freorder-functions")
    #pragma GCC optimize("-findirect-inlining")
    #pragma GCC optimize("-fhoist-adjacent-loads")
    #pragma GCC optimize("-frerun-cse-after-loop")
    #pragma GCC optimize("inline-small-functions")
    #pragma GCC optimize("-finline-small-functions")
    #pragma GCC optimize("-ftree-switch-conversion")
    #pragma GCC optimize("-foptimize-sibling-calls")
    #pragma GCC optimize("-fexpensive-optimizations")
    #pragma GCC optimize("-funsafe-loop-optimizations")
    #pragma GCC optimize("inline-functions-called-once")
    #pragma GCC optimize("-fdelete-null-pointer-checks")
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    #define int long long
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    double a, b, d;
    char c;
    signed main() {
    	cin >> a >> c >> b;
    	if(c == '+')//从此处开始逐个判断是哪一个运算符号
    		d = a + b;
    	else if(c == '-')
    		d = a-b;
    	else if(c == '*')
    		d = a*b;
    	else if(c == '/'){
    		if(b == 0){//不能除以零 
    			puts("No Answer.");
    			return 0;//输出后直接结束程序 
    		}
    		else
    			d = a / b;
    	}
    	else{//c可能不是运算符号 
    		puts("No Answer.");
    		return 0;
    	}
    	printf("%.2lf\n",d);
    	return 0;
    }
    

    纯享版:

    #include <stdio.h>
    #include <iostream>
    #define int long long
    using namespace std;
    double a, b, d;
    char c;
    signed main(){
    	cin >> a >> c >> b;
    	if(c == '+')
    		d = a + b;
    	else if(c == '-')
    		d = a-b;
    	else if(c == '*')
    		d = a*b;
    	else if(c == '/'){
    		if(b == 0){
    			puts("No Answer.");
    			return 0;
    		}
    		else
    			d = a / b;
    	}
    	else{
    		puts("No Answer.");
    		return 0;
    	}
    	printf("%.2lf\n",d);
    	return 0;
    }
    
    • 1
      @ 2022-10-29 22:36:56
      #include <bits/stdc++.h>
      
      using namespace std;
      
      int main()
      {
          float a, b;
      
          char c; 
      
          cin >> a >> c >> b;
      
          if (c == '+')
          {
              cout << fixed << setprecision(2) << a + b;
          }
          else if (c == '-')
          {
              cout << fixed << setprecision(2) << a - b;
          }
          else if (c == '*')
          {
              cout << fixed << setprecision(2) << a * b;
          }
          else if (c == '/')
          {
              if (b != 0)
              {
                  cout << fixed << setprecision(2) << a / b;
              }
              else
              {
                  cout << "No Answer.";
              }
          }
      
          return 0;
      }
      
      • 0
        @ 2023-6-30 20:08:22
        #include <iostream>
        #include <stdio.h>
        #include <iomanip>
        #include <math.h>
        using namespace std;
        const int N = 1e6 + 10;
        const int INF = 0x3f3f3f3f;
        int main()
        {
        	double a , b;
        	char c;
        	cin >> a >> c >> b;
        	if( c == '+' )
        	{
        		cout << fixed << setprecision(2) << a + b;
        	}
        	else if( c == '-' )
        	{
        		cout << fixed << setprecision(2) << a - b;
        	}
        	else if( c == '*' )
        	{
        		cout << fixed << setprecision(2) << a * b;
        	}
        	else if( c == '/' )
        	{
        		if( b == 0 )
        		{
        			cout << "No Answer.";
        		}
        		else
        		{
        			cout << fixed << setprecision(2) << a / b;
        		}
        	}
        	else
        	{
        		cout << "No Answer.";
        	}
        	return 0;
        }
        
        • -1
          @ 2024-10-4 9:43:58

          #include <stdio.h> #include <iostream> #include <math.h> #include <iomanip> using namespace std; int main() { float a,c; char b; cin>>a>>b>>c; if(b=='+'){ cout<<fixed<<setprecision(2)<<a+c; }else{ if(b=='-'){ cout<<fixed<<setprecision(2)<<a-c; }else{ if(b==''){ cout<<fixed<<setprecision(2)<<ac; }else{ if(b=='/'&&c!=0){ cout<<fixed<<setprecision(2)<<a/c; }else{ cout<<"No Answer."; } } } } return 0; }

          • -1
            @ 2024-7-27 19:30:06

            #include<iostream> #include<iomanip> using namespace std; int main(){

            while (true) { int n; double a,b,c; char f; cout<"请输入你要保留的小数位数:"; cin>n;

            cout<<endl<<"请输入算式:";
            cin>>a>>f>>b;
            if(f=='+'){
            	c=a+b;
            }
            if(f=='-'){
            	c=a-b;
            }else if(f=='*'){
            	c=a*b;
            }else if(f=='/'){
            	c=a/b;
            }
            cout<<fixed<<setprecision(n)<<c<<endl<<"——————————————————————————————————————————"<<endl;
            

            } }

            • -1
              @ 2024-5-29 20:25:04

              #include <iostream> #include <iomanip> using namespace std; int main() { float a, b; char c; cin >> a >> c >> b; if (c == '+') { cout << fixed << setprecision(2) << a + b; } else if (c == '-') { cout << fixed << setprecision(2) << a - b; } else if (c == '*') { cout << fixed << setprecision(2) << a * b; } else if (c == '/') { if (b != 0) { cout << fixed << setprecision(2) << a / b; } else { cout << "No Answer."; } } else { cout << "No Answer."; } return 0; }

              • -1
                @ 2024-4-12 21:43:12
                #include <bits/stdc++.h>
                #include <iostream>
                #include <stdio.h>
                #include <iomanip>
                #include <math.h>
                using namespace std;
                const int N = 1e6 + 10;
                const int INF = 0x3f3f3f3f;
                int main()
                {
                	double a , b;
                	char c;
                	cin >> a >> c >> b;
                	if( c == '+' )
                	{
                		cout << fixed << setprecision(2) << a + b;
                	}
                	else if( c == '-' )
                	{
                		cout << fixed << setprecision(2) << a - b;
                	}
                	else if( c == '*' )
                	{
                		cout << fixed << setprecision(2) << a * b;
                	}
                	else if( c == '/' )
                	{
                		if( b == 0 )
                		{
                			cout << "No Answer.";
                		}
                		else
                		{
                			cout << fixed << setprecision(2) << a / b;
                		}
                	}
                	else
                	{
                		cout << "No Answer.";
                	}
                	return 0;
                }
                
                
                
                • -2
                  @ 2023-4-4 21:02:15

                  #include<bits/stdc++.h> using namespace std; int main() { double a,b; char c; cin>>a>>c>>b; if(c=='+') cout<<fixed<<setprecision(2)<<a+b; else if(c=='-') cout<<fixed<<setprecision(2)<<a-b; else if(c=='') cout<<fixed<<setprecision(2)<<ab; else if(c=='/') if(b==0) cout<<"No Answer."; else cout<<fixed<<setprecision(2)<<a/b; else cout<<"No Answer."; return 0; }

                  • -2
                    @ 2022-1-23 14:11:43
                    #include <iostream>
                    #include <iomanip>
                    using namespace std;
                    char a[5];
                    int main(){
                        long double n,m;
                        cin>>n>>a[0]>>m;
                        if(a[0]=='+')
                            cout<<fixed<<setprecision(2)<<n+m;
                        else if(a[0]=='-')
                            cout<<fixed<<setprecision(2)<<n-m;
                        else if(a[0]=='*')
                            cout<<fixed<<setprecision(2)<<n*m;
                        else{
                            if(m==0){
                                cout<<"No Answer.";
                                return 0;
                            }
                            cout<<fixed<<setprecision(2)<<n/m;
                        }
                        return 0;
                    }
                    • -3
                      @ 2023-1-19 20:04:48
                      #include<bits/stdc++.h>
                      using namespace std;
                      int main(){
                      	double a,c;
                      	char b;
                      	cin>>a>>b>>c;
                      	if(b=='+'){
                              cout<<fixed<<setprecision(2)<<a+c;
                      	}
                      	else if(b=='-'){
                              cout<<fixed<<setprecision(2)<<a-c;
                      	}
                      	else if(b=='*'){
                              cout<<fixed<<setprecision(2)<<a*c;
                      	}
                      	else if(b=='/'){
                      		if(c!=0)
                              	cout<<fixed<<setprecision(2)<<a/c;
                      		else
                      			cout<<"No Answer.";
                      	}else{
                      		cout<<"No Answer.";
                      	}
                      }
                      
                      • -3
                        @ 2022-1-2 16:07:46
                        /*****************************************
                        备注:
                        ******************************************/
                        #include <queue>
                        #include <math.h>
                        #include <stack>
                        #include <stdio.h>
                        #include <iostream>
                        #include <vector>
                        #include <iomanip>
                        #include <string.h>
                        #include <algorithm>
                        using namespace std;
                        #define LL long long
                        const int N = 1e5 + 10;
                        const int INF = 0x3f3f3f3f;
                        int main()
                        {
                        	double a,b;
                        	char c;
                        	cin >> a >> c >> b;
                        	double d;
                        	if(c == '+')
                        		d = a + b;
                        	else if(c == '-')
                        		d = a-b;
                        	else if(c == '*')
                        		d = a*b;
                        	else 
                        	{
                        		if(b == 0)
                        		{
                        			cout << "No Answer.";
                        			return 0;
                        		}
                        		else
                        			d = a/b;
                        	}
                        	printf("%.2lf\n",d);
                        	return 0;
                        }
                        
                        • -3
                          @ 2022-1-2 16:06:49
                          /*****************************************
                          备注:
                          ******************************************/
                          #include <queue>
                          #include <math.h>
                          #include <stack>
                          #include <stdio.h>
                          #include <iostream>
                          #include <vector>
                          #include <iomanip>
                          #include <string.h>
                          #include <algorithm>
                          using namespace std;
                          #define LL long long
                          const int N = 1e5 + 10;
                          const int INF = 0x3f3f3f3f;
                          int main()
                          {
                          	double a,b;
                          	char c;
                          	cin >> a >> c >> b;
                          	double d;
                          	if(c == '+')
                          		d = a + b;
                          	else if(c == '-')
                          		d = a-b;
                          	else if(c == '*')
                          		d = a*b;
                          	else 
                          	{
                          		if(b == 0)
                          			cout << "No Answer.";
                          		else
                          			d = a/b;
                          	}
                          	if( !( b == 0 && c == '/'))
                          		printf("%.2lf\n",d);
                          	return 0;
                          }
                          
                          • 1

                          信息

                          ID
                          859
                          时间
                          1000ms
                          内存
                          128MiB
                          难度
                          8
                          标签
                          递交数
                          1918
                          已通过
                          335
                          上传者