1 条题解

  • 0
    @ 2025-4-7 21:29:25

    C :

    #include<stdio.h>
    void main()
    {
    	int x,y;
    	scanf("%d",&x);
    	if(x<1)
    		y=x;
    	else if(1<=x&&x<10)
    		y=2*x-1;
    	else
    		y=3*x-11;
    	printf("%d\n",y);
    }
    

    C++ :

    #include<iostream>
    #include<fstream>
    #include<string>
    #include<cstring>
    #include<cmath>
    using namespace std;
    
    int main()
    {
    	//ifstream cin("aaa.txt");
    	int i,j,n,m,x1,x2,x3,x4,len;
    	cin>>n;
    	if(n<1) cout<<n;
    	else if(n<10) cout<<2*n-1;
    	else cout<<3*n-11;
    	cout<<endl;
    	
    
    
    return 0;
    }
    	
    

    Pascal :

    var
    x:longint; 
    begin
     read(x); 
     if x<1 then write(x); 
     if (x>=1)and(x<10)then write(2*x-1); 
     if x>=10 then write(3*x-11); 
    end. 
     
    
    
    • 1

    信息

    ID
    1414
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者