내가 디버거 (onlinegdb)의C++ 벡터 입력 - 런타임 오류 - 아웃 디버깅 시간을 - 실패 FIRST FOR LOOP
2 1 /newline/
4
출력으로 표준 입력 내 C++ 프로그램을 디버깅하려고 : - 동안 두 번째 줄은 질문에 의해 제공되는 또 다른 입력 자료를 읽는 중이었습니다. 이번에는 벡터 arr이 출력을 표시하지 않습니다 4 args를 설정하십시오 /home/a.out..done에서 기호를 읽는 중입니다.
(gdb) continue
프로그램이 실행되고 있지 않습니다.
(GDB) 실행
Starting program: /home/a.out </home/input.txt
2 1
P.S. The program successfully compiles and runs for user provided input
3 2
3
4
P.S. 프로그램의 루프가 처음으로 올바르게 실행되지 않는 이유는 무엇입니까?
는 소스 코드 -
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int m;
cin>>m;
int t;
cin>>t;
cout<<m<<" "<<t<<"\n";
int sum=0;
vector<int> arr(t);
for(int i=0;i<t;i++)
cin>>arr[i]; //arr[i]=k digit nos
for(int i=0;i<t;i++)
cout<<arr[i]<<" ";
int comb(int a, int b); //6,2
for(int i=0;i<t;i++)
{
if(m==arr[i]){
cout<<m<<" a "<<9*pow(10,m-1)<<"\n";
}
if(m>arr[i]){
cout<<m<<" b "<<9*pow(10,m-1)<<"\n";
}
if(m<arr[i]){
/*if(m==arr[i]-1){
cout<<m<<" c "<<9*pow(10,arr[i]-1)-9<<"\n";
}
else{*/
sum=pow(10,arr[i])-1;
for(int j=arr[i]-1;j>m;j++)
sum=sum-comb(arr[i],j)*pow(9,arr[i]-j+1);
cout<<" d "<<sum<<"\n";
//}
}
}
//for m upto 10^4, k<=10^5; else k=10^5
return 0;
}
int comb(int a, int b) { //6,2
int j=1;
int s=a;
for(int k=a-1;k>b;k--) //5,4,3
s=s*k;
for(int l=1;l<=b;l++)
s=s/l;
return s;
}
//It is a problem involving displaying number of integers with no digit //repeating more than m (=2 here) times for t(=1) inputs with each input //being a arr[i] (=4) digit number.