没有能够解决有关该code拼图 [英] Not able to solve the puzzle regarding this code

查看:92
本文介绍了没有能够解决有关该code拼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int i,n=20;
for(i=0;i<n;i--)
printf("-");


我一直剑拔弩张我的大脑,但一直没能解决此问题。


I have been rattling my brain but have not been able to solve this.

删除任何单个字符或操作员从上面code和程序应打印 - 20倍

Delete any single character or operator from above code and the program should print "-" 20 times

请帮帮忙!

推荐答案

我不认为你可以通过的删除字符做,但我有三个解决方案,替换(当然,其中一人增加了一个角色,但只是因为你在你的程序中没有空格。如果你有空格,它会取代一个空格)。

I don't think you can do it by deleting a character, but I have three solutions that replace (well, one of them adds a character, but only because you have no whitespace in your program. If you had whitespace, it would replace a space).

解决方案1 ​​

int i,n=20;
for(i=0;-i<n;i--) // -i < n 
    printf("-");

解决方案2

int i,n=20;
for(i=0;i<n;n--) // n-- 
    printf("-");

解决方案3

int i,n=20;
for(i=0;i+n;i--) // while i + n is not zero 
    printf("-");

这篇关于没有能够解决有关该code拼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆