1 条题解

  • 0
    @ 2025-4-12 21:36:06

    C :

    #include<stdio.h>
    int main(){
    int i=1;
    while(i<=25){
        if((i==10)||(i==15)||(i==20)||(i==25)) printf("%d\n",i);
        else if(i==5) printf(" %d\n",i);
        else if(i<=10) printf(" %d ",i);
        else if(i<=25) printf("%d ",i);
        i=i+1;
    }
    return 0;
    }
    
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	for(int i=1;i<=10;i++){
    		if(i == 1 || i ==6)
    			cout<<" "<<i;
    		else if( i<10)
    			cout<<"  "<<i;
    		else
    			cout<<" "<<i;
    		if(i%5 == 0)
    			cout<<endl;
    	}
    	for(int j=11;j<=25;j++){
    		if(j%5 == 0)
    		    cout<<j<<endl;
    		else
    			cout<<j<<" ";
    	}
    	return 0;	
    }
    

    Pascal :

    begin
      writeln(' 1  2  3  4  5');
      writeln(' 6  7  8  9 10');
      writeln('11 12 13 14 15');
      writeln('16 17 18 19 20');
      writeln('21 22 23 24 25');
    end.
    

    Java :

    public class Main 
        {
                public static void main(String[] args)
                {
                  
                  for(int i = 1;i<=25;i++) {
                         System.out.printf("%2d",i);
                    if(i%5!=0)
                      System.out.print(" ");
                    else
                      System.out.print("\n");
                      
                      
                    }
                  
                }
    }
    
    • 1

    信息

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