1 条题解

  • 0
    @ 2023-3-13 12:11:54

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    
    int main() {
    	int n;
    	double h,a[110];
    	cin>>h>>n;
    	for(int i = 1;i <= n;i++){
    		cin>>a[i];
    	}
    	
    	cout<<fixed<<setprecision(2)<<h<<" ";
    	for(int i = 1;i <= n;i++){
    		cout<<fixed<<setprecision(2)<<h+a[i]<<" ";
    	}
    	
    	
    	return 0;
    }
    
    

    Pascal :

    var a:array[1..100] of real;
        n,i:longint;
        h:real;
    begin
      readln(h,n);
      for i:=1 to n do read(a[i]);
      for i:=1 to n do
      if a[i]>=0 then a[i]:=h+a[i]
                 else a[i]:=h+a[i];
      write(h:0:2,' ');
      for i:=1 to n do write(a[i]:0:2,' ');
      end.
    
    
    
    • 1

    信息

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