xxxxxxxxxx
#include<stdio.h>
int main()
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n*n;j++)
{
print(I'll);
}
}
return 0;
}
xxxxxxxxxx
sum=0;
for (int j=n ; j >0 ; j=j/2)
{
for (i= j ; i <=n ; i=i*2)
{
sum++;
}
}
xxxxxxxxxx
class Solution {
public:
int minStoneSum(vector<int>& piles, int k) {
int sum=accumulate(piles.begin(), piles.end(), 0);
while(k!=0){
int i=*max_element(piles.begin(),piles.end());
std::vector<int>::iterator it = std::find(piles.begin(), piles.end(), i);
int index = std::distance(piles.begin(), it);
int t=floor(piles[index]/2);
piles[index]=i-t;
sum=sum-t;
k--;
}
return sum;
}
};
xxxxxxxxxx
func eatChips(int bowlOfChips) {
Println("Have some chips!")
for chips := 0; chips <= bowlOfChips; chips++ {
// dip chips
}
Println("No more chips.")
}
func pizzaDelivery(int boxesDelivered) {
Println("Pizza is here!")
for pizzaBox := 0; pizzaBox <= boxesDelivered; pizzaBox++ {
// open box
[1]
[2]
[2]
[2]
United International University (UIU)
Dept. of Computer Science & Engineering (CSE)
Mid Exam Year: 2021 Trimester: Summer
Course: CSE 2217/CSI 227 Data Structure and Algorithms II,
Total Marks: 20, Time: 1 hour, Upload & Download: 15 min
2
for pizza := 0; pizza <= pizzaBox; pizza++ {
// slice pizza
for slice := 0; slice <= pizza; slice++ {
// eat slice of pizza
}
}
}
Println("Pizza is gone.")
}