Skip to content

Instantly share code, notes, and snippets.

@KOBA789
Last active August 29, 2015 14:00
Show Gist options
  • Save KOBA789/11257753 to your computer and use it in GitHub Desktop.
Save KOBA789/11257753 to your computer and use it in GitHub Desktop.
nabeatsu
/*
Nabeatsu without string manipulations
Copyright (C) 2014 KOBA789
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
int is_including (int k, int n) {
int i;
for (i = 1; i <= n; i = i * 10) {
if (n / (i * 10) * 10 == n / i - k) {
return 1;
}
}
return 0;
}
int main (void) {
int i;
for (i = 1; i <= 100; ++i) {
printf("%d", i);
if (i % 3 == 0 || is_including(3, i)) {
printf(" aho");
}
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment