1 solutions

  • 0
    @ 2025-11-5 17:32:24

    C++ :

    #include<cstdio>
    using namespace std;
    int main()
    {
    	int i,n,s=0;
    	scanf("%d",&n);
    	for(i=1;i<=n;i++)
    	{
    		if(n%i==0)s++;
    	}
    	printf("%d\n",s);
    	return 0; 
    }
    

    Pascal :

    var
        s,i,n:integer;
    begin
        readln(n);
        for i:=1 to n do begin
            if n mod i=0 then s:=s+1;
        end;
        writeln(s);
    end.
    
    • 1

    第五章:for+if结构《练习2:计算n的不同因数的个数》

    Information

    ID
    18537
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By