我有一个名为pages的c ++堆栈.由于我没有clear()函数来清除堆栈,我编写了以下代码:
stack<string> pages;
//here is some operation
//now clearing the stack
while(!pages.empty())
pages.pop();
Run Code Online (Sandbox Code Playgroud)
现在我的问题是:有更好的方法来清除堆栈吗?提前致谢.
我有一对对.我想在这个数组上使用memset来生成0,1或-1.我该怎么做?这是我们一直做的正常程序吗?
该对和数组是:
std::pair<int, int> ar[100][100];
Run Code Online (Sandbox Code Playgroud) 我有一个用户模型,其中包含 id、name、email 和
包含列 id、name、code 和
数据透视表 course_user。
Course 和 User 是多对多的关系
course_user 表包含列 course_id、user_id、section
在参加课程时,一些用户将在数据透视部分列中列为“待定”,而一些用户将在部分列中列为“A”、“B”等。
问题:我想获得至少由一位用户参加的课程,并且部分是“待定”到目前为止,我已经尝试了这些:在课程模型中:
public function users(){
return $this->belongsToMany(User::class)
->withPivot('section');
->wherePivot('section', 'Pending');
}
Run Code Online (Sandbox Code Playgroud)
我在课程模型中尝试过的另一种方法:
public function pendingUsers(){
return $this->belongsToMany(User::class)
->withPivot('section')
->wherePivot('section', 'like', 'Pending');
}
Run Code Online (Sandbox Code Playgroud)
但所有这些都给了我所有的课程。现在,如何完成这项工作?
我在 Laravel 项目中使用 dompdf。我正在尝试生成一个包含表格的 PDF。表格的所有数据正在生成,但表格边框未显示。
但是当我在浏览器中生成 html 时,它可以在表格的 100% 宽度下正常工作,但在 PDF 中却无法获得 100% 宽度。
我的控制器代码:
$users = $course->users()
->withPivot('section_id')
->wherePivot('section_id', '=', $section->id)
->orderBy('student_id', 'asc')
->get();
$season = Season::where('is_ended', 0)->first();
$pdf = PDF::loadView('sections.attendace', compact('users', 'course', 'season', 'section'));
return $pdf->stream('attendance.pdf');
Run Code Online (Sandbox Code Playgroud)
刀片代码:
<div class="attendance-table">
<table class="table-bordered">
<tr>
<th class="attendance-cell">ID</th>
<th class="attendance-cell">Name</th>
@for($i = 1; $i<=9; $i++)
<th class="blank-cell attendance-cell">{{$i}}</th>
@endfor
</tr>
@foreach($users as $user)
<tr>
<td class="attendance-cell">{{$user->student_id}}</td>
<td class="attendance-cell">{{ucwords($user->name)}}</td>
@for($i = 1; $i<=9; $i++)
<td class="blank-cell attendance-cell">{{$i}}</td>
@endfor
</tr>
@endforeach
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS …