#include <iostream>
using namespace std;
int main()
{
int n,k,a,b;
cout <<"請輸入燈的總數和人的總數(燈的總數大于等于人的總數小于等于1000)分別為:";
cin >>n>>k;
a=n;b=k;
int light[a][b]={0};
for (b=0;b<k;b++)
for (a=0;a<n;a++)
if((a+1)%(b+1)==0)
light [a][b]++;
for (a=0;a<n;a++)
for (b=1;b<k;b++)
light[a][0]+=light[a][b];
for (a=0;a<n;a++)
if (light[a][0]%2==1)
cout <<a+1<<" ";
return 0;}
陣列應用常量定義,但是我用的是變數,為什么也可以運行,而且結果正確?
求大神解答。
uj5u.com熱心網友回復:
難道是C++新標準支持的語法?轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/53535.html
標籤:基礎類
上一篇:用c++實作串的功能,但老是出現error C2228: left of '.StringLength' must have class/struct/u錯誤!
