Mrowqa

Visual C++ 2012 Bug

Jul 20th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. /**
  2.  * This code shows Visual C++ 2012 bug
  3.  * Code by Artur "Mrowqa" Jamro
  4.  */
  5.  
  6. #define _CRT_SECURE_NO_WARNINGS
  7.  
  8. #include <cstdio>
  9. #include <algorithm>
  10. #include <cstring>
  11. using namespace std;
  12.  
  13. int main() {
  14.     char word[235];
  15.     unsigned char ch[128] = {0};
  16.     short roz[128] = {0};
  17.     bool isPrime[235] = { false, false, true, true, false };
  18.     int wLen=0;
  19.     scanf("%s", word);
  20.     for(char*it=word,wLen=0; *it; ++it, ++wLen) // here's initialization
  21.         ch[*it]++,roz[wLen+1]++;
  22.     for(char i='a'; i<='z'; ++i)
  23.         while(ch[i]) roz[ch[i]--]--;
  24.  
  25.     for(int i=4; i<=wLen; ++i) // and here's debugger error (http://puu.sh/3HAbG.png)
  26.         if(roz[i]!=0)
  27.         {
  28.             int ii=i;
  29.             for(int j=2;j<ii;++j) {
  30.                 while(ii%j==0) {
  31.                     ii/=j;
  32.                     roz[j]+=roz[i];
  33.                 }
  34.             }
  35.             if(ii==i)
  36.                 isPrime[ii]=true;
  37.             else
  38.                 roz[i]=0;
  39.         }
  40.  
  41.     int maxPrime = 2;
  42.     for(int i=2; i<=wLen; i++)
  43.         if(roz[i]!=0)  maxPrime = i;
  44.  
  45.     for(int i=2; i<=maxPrime; ++i)
  46.         if(isPrime[i]) printf("%i ", roz[i]);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment